public ActionResult AddReport(ReportModel report, string uid) { var nullremove = new dataFormatHandler(); report = nullremove.RemoveNulls(report); dataHandler.ReportSighting(report); return(RedirectToAction("PostTheEditedProfile", "Home", new { uid = uid })); }
public ActionResult PostTheEditedProfile(Item2 form, HttpPostedFileBase file) { string imagePath2 = ""; WebImage photo = null; var newFileName = ""; var imagePath = ""; Item2 Data = form; var dataFormat = new dataFormatHandler(); if (ModelState.IsValid) { //try //{ if (file != null) { photo = WebImage.GetImageFromRequest(); if (photo != null) { newFileName = Guid.NewGuid().ToString() + "_" + Path.GetFileName(photo.FileName); imagePath = @"~/uploads/" + newFileName; //string imagePath = @"images\" + photo.FileName; //photo.Save(@"~\" + imagePath); imagePath2 = Server.MapPath(imagePath); } //Extract Image File Name. //string fileName = System.IO.Path.GetFileName(file.FileName); ////Set the Image File Path. //string filePath = Path.Combine("~/UploadedFiles/", fileName); /*"~/UploadedFiles/" + fileName;*/ ////Save the Image File in Folder. //file.SaveAs(Server.MapPath(imagePath2)); file.SaveAs(Server.MapPath(imagePath)); //Insert the Image File details in Table. //FilesEntities entities = new FilesEntities(); //entities.Files.Add(new File //{ // Name = fileName, // Path = filePath //}); //entities.SaveChanges(); List <string> tempImages = Data.images.ToList(); tempImages.Add(imagePath); tempImages.Add(imagePath2); Data.images = tempImages.ToArray(); } else { Data.file = dataFormat.stringIsNull(Data.file); Data.images[0] = dataFormat.stringIsNull(Data.images[0]); } ViewBag.FileStatus = "File uploaded successfully."; //} //catch (Exception) //{ // ViewBag.FileStatus = "Error while file uploading."; //} } Data.caution = dataFormat.stringIsNull(Data.caution); Data.description = dataFormat.stringIsNull(Data.description); Data.uid = dataFormat.stringIsNull(Data.uid); Data.title = dataFormat.stringIsNull(Data.title); //if (Data.reward_max = null) //{ // Data.reward_max = 0; //} if (Data.locations == null) { Data.locations = new string[] { "null" }; } Data.status = dataFormat.stringIsNull(Data.status); Data.nationality = dataFormat.stringIsNull(Data.nationality); Data.locations[0] = dataFormat.stringIsNull(Data.locations[0]); dataHandler.UpdateAProfile(Data); return(View(Data)); }