public IActionResult EditPersonalDetail(PersonalDetail personDetail) { if (ModelState.IsValid) { if (Request.Form.Files["profile-image"] != null) { //saving if (Request.Form.Files["profile-image"].Length > 10 * 1024 * 1024) { personDetail.ErrorMsg = "File is not within size limit of 10MB."; return(View(personDetail)); } string pathToFolder = Path.Combine(_env.WebRootPath, "UploadedFiles", Request.Form.Files["profile-image"].FileName); var fileStream = new FileStream(pathToFolder, FileMode.Create); Request.Form.Files["profile-image"].CopyTo(fileStream); personDetail.ImageLocation = "UploadedFiles" + Request.Form.Files["profile-image"].FileName; } var personInList = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personDetail.PersonalDetailId).FirstOrDefault(); personInList.FirstName = personDetail.FirstName; personInList.Occupation = personDetail.Occupation; personInList.Age = personDetail.Age; personInList.Address = personDetail.Address; personInList.ImageLocation = personDetail.ImageLocation; return(RedirectToAction("Persons")); } else { return(View(personDetail)); } }
public IActionResult PersonalDetailsEdit(int personDetailsID) { PersonalDetails pdetail = new PersonalDetails(); pdetail = PersonMemory.GetPersons().Where(x => x.PersonalDetailsID == personDetailsID).FirstOrDefault(); return(View(pdetail)); }
public IActionResult PersonalDetailDelete(int personDetailId) { var person = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personDetailId).FirstOrDefault(); PersonMemory.GetPersons().Remove(person); return(RedirectToAction("Persons")); }
public IActionResult CreatePerson(PersonalDetail person) { if (ModelState.IsValid) { if (Request.Form.Files["profile-image"] != null) { //saving if (Request.Form.Files["profile-image"].Length > 10 * 1024 * 1024) { person.ErrorMsg = "File is not within size limit of 10MB."; return(View(person)); } string pathToFolder = Path.Combine(_env.WebRootPath, "UploadedFiles", Request.Form.Files["profile-image"].FileName); var fileStream = new FileStream(pathToFolder, FileMode.Create); Request.Form.Files["profile-image"].CopyTo(fileStream); person.ImageLocation = pathToFolder; /*person.ImageLocation = "UploadedFiles" + Request.Form.Files["profile-image"].FileName;*/ } var personDetailList = PersonMemory.GetPersons(); int personsCount = personDetailList.Count; person.PersonalDetailId = ++personsCount; personDetailList.Add(person); return(RedirectToAction("Persons")); } else { return(View(person)); } }
public ViewResult PersonalDetailEdit(int personDetailId) { PersonalDetail pdetail = new PersonalDetail(); pdetail = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personDetailId).FirstOrDefault(); return(View(pdetail)); }
public ActionResult CretePersonDetail(PersonalDetail pd) { if (Request.Form.Files["profile-image"] != null) { //saving if (Request.Form.Files["profile-image"].Length > 10 * 1024 * 1024) { pd.ErrorMsg = "File Size not valid !!"; return(View(pd)); } string pathToFolder = Path.Combine(_env.WebRootPath, "uploadedfiles", Request.Form.Files["profile-image"].FileName); using (var fileStreams = new FileStream(pathToFolder, FileMode.Create)) { Request.Form.Files["profile-image"].CopyTo(fileStreams); pd.ImageLocation = pathToFolder; fileStreams.Flush(); } } var persondetailList = PersonMemory.GetPersons(); int currentPersonCount = persondetailList.Count; currentPersonCount = currentPersonCount + 1; pd.PersonalDetailId = currentPersonCount; persondetailList.Add(pd); return(RedirectToAction("Persons")); }
public IActionResult PersonalDetail(int personDetailId) { PersonalDetail pdetail = new PersonalDetail(); pdetail = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personDetailId).FirstOrDefault(); return(View(pdetail)); //return new ObjectResult(pdetail); }
public IActionResult CreatePersonDetail(PersonalDetails pd) { var personDetailList = PersonMemory.GetPersons(); int currentPersonCount = personDetailList.Count; pd.PersonalDetailsID = ++currentPersonCount; personDetailList.Add(pd); return(RedirectToAction("PDEditor")); }
//public IActionResult DownloadFile(int personId) //{ // string downlloadPath = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personId).FirstOrDefault().ImageLocation; //return File() //} public FileResult DownloadFile(int personId) { string downlloadPath = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personId).FirstOrDefault().ImageLocation; //string[] extension = downlloadPath.Split('/'); //string filename = extension[2].ToString(); string pathToFolder = Path.Combine(_env.WebRootPath, downlloadPath); var fileStream = new FileStream(pathToFolder, FileMode.Open); return(File(fileStream, "image/jpeg", "downloadedfile.jpg")); }
public ActionResult CretePersonDetail(PersonalDetail pd) { var persondetailList = PersonMemory.GetPersons(); int currentPersonCount = persondetailList.Count; currentPersonCount = currentPersonCount + 1; pd.PersonalDetailId = currentPersonCount; persondetailList.Add(pd); return(RedirectToAction("Persons")); }
public IActionResult CreatePerson(PersonalDetail person) { var personDetailList = PersonMemory.GetPersons(); int personsCount = personDetailList.Count; person.PersonalDetailId = ++personsCount; personDetailList.Add(person); return(RedirectToAction("Persons")); }
public IActionResult PersonalDetailsEdit(PersonalDetails pd) { var personInList = PersonMemory.GetPersons().Where(x => x.PersonalDetailsID == pd.PersonalDetailsID).FirstOrDefault(); personInList.FirstName = pd.FirstName; personInList.Address = pd.Address; personInList.Age = pd.Age; personInList.Occupation = pd.Occupation; return(RedirectToAction("PDEditor")); }
public ActionResult PersonalDetailEdit(PersonalDetail pd) { if (ModelState.IsValid) { //reference type variable var personInList = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == pd.PersonalDetailId).FirstOrDefault(); personInList.FirstName = pd.FirstName; personInList.Occupation = pd.Occupation; personInList.Age = pd.Age; personInList.Address = pd.Address; return(RedirectToAction("Persons")); } else { return(View(pd)); } }
public IActionResult EditPersonalDetail(PersonalDetail personDetail) { if (ModelState.IsValid) { var personInList = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == personDetail.PersonalDetailId).FirstOrDefault(); personInList.FirstName = personDetail.FirstName; personInList.Occupation = personDetail.Occupation; personInList.Age = personDetail.Age; personInList.Address = personDetail.Address; return(RedirectToAction("Persons")); } else { return(View(personDetail)); } }
public async Task <ActionResult> PersonalDetailEdit(PersonalDetail pd) { if (ModelState.IsValid) { if (Request.Form.Files["profile-image"] != null) { //saving if (Request.Form.Files["profile-image"].Length > 10 * 1024 * 1024) { pd.ErrorMsg = "File Size not valid !!"; return(View(pd)); } string pathToFolder = Path.Combine(_env.WebRootPath, "uploadedfiles", Request.Form.Files["profile-image"].FileName); var fileStream = new FileStream(pathToFolder, FileMode.Create); //await Task.Run(() >{ await Request.Form.Files["profile-image"].CopyToAsync(fileStream); //}); pd.ImageLocation = "uploadedfiles/" + Request.Form.Files["profile-image"].FileName; } //reference type variable var personInList = PersonMemory.GetPersons().Where(x => x.PersonalDetailId == pd.PersonalDetailId).FirstOrDefault(); personInList.FirstName = pd.FirstName; personInList.Occupation = pd.Occupation; personInList.Age = pd.Age; personInList.Address = pd.Address; personInList.ImageLocation = pd.ImageLocation; return(RedirectToAction("Persons")); } else { return(View(pd)); } }
public IActionResult Persons() { return(View(PersonMemory.GetPersons())); }