TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Indu Yadav
NA
254
56.9k
check my code for update operation in mvc4
Apr 17 2017 4:44 AM
Hello
Ramesh Palanivale
Please check my code..........
[HttpGet]
public ActionResult EditData(int Candidate_Id)
{
var image = context.Applications.Find(Candidate_Id);
if (image == null)
{
return new HttpNotFoundResult();
}
var model = new Application
{
Name = image.Name,
Father_Name=image.Father_Name,
Photograph=image.Photograph,
Candidate_signature=image.Candidate_signature,
Gender=image.Gender,
DOB=image.DOB,
course=image.course,
appearing_class=image.appearing_class,
Contact_No1=image.Contact_No1,
Contact_No2=image.Contact_No2,
Email_Id=image.Email_Id,
Residence=image.Residence,
Exam_center_code=image.Exam_center_code,
Category=image.Category,
Occupation_father=image.Occupation_father,
Income=image.Income,
City=image.City,
State=image.State,
Mail_Id1=image.Mail_Id1,
Mail_Id2=image.Mail_Id2,
};
return View(model);
}
[HttpPost]
[ValidateInput(false)]
public ActionResult EditData(Application model, int Candidate_Id)
{
if (ModelState.IsValid)
{
var image= context.Applications.Find(Candidate_Id);
if (image == null)
{
return new HttpNotFoundResult();
}
image.Name=model.Name;
image.Father_Name=model.Father_Name;
image.Photograph=model.Photograph;
image.Candidate_signature=model.Candidate_signature;
image.Gender=model.Gender;
image.DOB=model.DOB;
image.course=model.course;
image.appearing_class=model.appearing_class;
image.Contact_No1=model.Contact_No1;
image.Contact_No2=model.Contact_No2;
image.Email_Id=model.Email_Id;
image.Residence=model.Residence;
image.Exam_center_code=model.Exam_center_code;
image.Category=model.Category;
image.Occupation_father=model.Occupation_father;
image.Income=model.Income;
image.City=model.City;
image.State=model.State;
image.Mail_Id1=image.Mail_Id1;
image.Mail_Id2=image.Mail_Id2;
if (model.Photograph != null)
{
var imagePath = Path.GetFileName(image.Photograph);
var imageUrl = System.IO.Path.Combine(Server.MapPath("~/PICS/"), imagePath);
image.Photograph = imageUrl;
}
context.SaveChanges();
return RedirectToAction("Index");
}
return View(model);
}
Reply
Answers (
3
)
update operation for image uploading
to display selected checkbox as checked in mvc