Special Task List
Special Task List
Special exercises :
1. Write a program to allow user to upload Excel file and read data from excel and store it
into database, columns are as follows.
I.e. 2 lowercase, 1 upercase, 1 numeric, 2 special character etc where number should be
choose by user.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2.Controllers
{
public class Policy
{
public int minlen { get; set; }
public int uppercase { get; set; }
public int lowercase { get; set; }
public int numeric { get; set; }
public int sp_char { get; set; }
}
}
Password.cshtml:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
ViewBag.Title = "Password";
}
<h2></h2>
<!DOCTYPE html>
<html>
<head>
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031
<div class="form-horizontal">
<h4>Policy</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.minlen, htmlAttributes: new
{@class ="control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.minlen, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.minlen, "", new
{
@class =
"text-danger"
})
</div>
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031
</div>
<div class="form-group">
@Html.LabelFor(model => model.uppercase, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.uppercase, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.uppercase, "", new
{
@class
= "text-danger"
})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.lowercase, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.lowercase, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.lowercase, "", new
{
@class
= "text-danger"
})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.numeric, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.numeric, new
{
htmlAttributes = new
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.numeric, "", new
{
@class =
"text-danger"
})
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.sp_char, htmlAttributes: new
{
@class =
"control-label col-md-2"
})
<div class="col-md-10">
@Html.EditorFor(model => model.sp_char, new
{
htmlAttributes = new
{
@class = "form-control"
}
})
@Html.ValidationMessageFor(model => model.sp_char, "", new
{
@class =
"text-danger"
})
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
@*<div>
@Html.ActionLink("Back to List", "Index")
</div>*@
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
HomeController.cs:
using WebApplication2.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication2.Controllers
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031
{
public class HomeController : Controller
{
static Policy Policy = new Policy();
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(int minLen, int uppercase, int lowercase, int
numeric, int sp_char)
{
Policy.minlen = minLen;
Policy.uppercase = uppercase;
Policy.lowercase = lowercase;
Policy.numeric = numeric;
Policy.sp_char = sp_char;
return RedirectToAction("Password");
}
public ActionResult Password()
{
return View();
}
[HttpPost]
public ActionResult Password(string Pwd)
{
String errmsg = "Passwors is according to the policy";
int uppercase = 0;
int lowercase = 0;
int sp_char = 0;
int numeric = 0;
if (Pwd.Length < Policy.minlen)
{
errmsg = "Please setisfy the minimum length of the password which is "
+ Policy.minlen;
}
for (int i = 0; i < Pwd.Length; i++)
{
if (Pwd[i] >= 65 && Pwd[i] <= 90) uppercase++;
else if (Pwd[i] >= 97 && Pwd[i] <= 122) lowercase++;
else if (Pwd[i] >= 48 && Pwd[i] <= 57) numeric++;
else sp_char++;
}
if (lowercase < Policy.lowercase ||
uppercase < Policy.uppercase || numeric < Policy.numeric ||
sp_char < Policy.sp_char)
{
errmsg = "Password is not according to the enterd policy";
}
ViewBag.errormsg = errmsg;
return View();
}
public ActionResult About()
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
3. Write a program to allow user to login with Google authenticator OTP code.
HomeController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace SpecialTaslThree.Controllers
{
[Authorize]
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
Index.cshtml:
@model Webapplication2.Models.Login
@{
/**/
ViewBag.Title = "Login";
}
< h2 > Login </ h2 >
@if(ViewBag.Status == null || !ViewBag.Status)
Marwadi University
Faculty of Engineering and Technology
Department of Information and Communication
Technology
Subject: .NET Technology
(01CT1518)
Date: 05/11/2023 Enrolment No: 92100133031
{
< div > @ViewBag.Message </ div >
< div >
@using(Html.BeginForm())
{
@Html.AntiForgeryToken()
< div class= "form-horizontal" >
< hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
< div class= "form-group" >
@Html.LabelFor(model => model.UserName, htmlAttributes: new
{
@class = "control-label col-md-2"
})
< div class= "col-md-10" >
@Html.EditorFor(model => model.UserName, new
{
htmlAttributes
= new { @class = "form-control" }
})
@Html.ValidationMessageFor(model => model.UserName, "", new
{
@class = "text-danger"
})
</ div >
</ div >
< div class= "form-group" >
@Html.LabelFor(model => model.Password, htmlAttributes: new
{
@class = "control-label col-md-2"
})
< div class= "col-md-10" >
@Html.EditorFor(model => model.Password, new
{
htmlAttributes
= new { @class = "form-control" }
})
@Html.ValidationMessageFor(model => model.Password, "", new
{
@class = "text-danger"
})
</ div >
</ div >
< div class= "form-group" >
< input type = "submit" value = "Create" class= "btn btn-default" />
UserProfile.cshtml:
@{
ViewBag.Title = "UserProfile";
}
< h2 > UserProfile </ h2 >
< h3 > @ViewBag.Message </ h3 >