public ActionResult JsonToDBExe(HttpPostedFileBase file) { string status; try { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); file.SaveAs(Path.Combine(directory, fileName)); } JsonManager <Executor> jman = new JsonManager <Executor>(); List <Executor> customers = jman.ReadFile(directory, file.FileName); foreach (Executor c in customers) { _custManager.GetAll().Find(x => x.Id == c.CustomerId).Executors.Add(c); _exeManager.Create(c); } status = "Success"; } catch (Exception e) { status = e.Message; } return(RedirectToAction("Index", new { statusMesage = status })); }
public ActionResult CreatePost(Executor executor) { try { Customer cu = _custManager.GetAll().FirstOrDefault(c => c.Email == User.Identity.Name); ServiceIndustry service = _servIndManager.GetAll().FirstOrDefault(s => s.Name == executor.ServiceIndustry.Name); executor.Customer = cu; executor.CustomerId = cu.Id; executor.ServiceIndustry = service; executor.ServiceIndustryId = service.ServiceIndustryId; service.Executors.Add(executor); cu.Executors.Add(executor); executor.ExecutorId = Guid.NewGuid().ToString(); executor.CreationTime = DateTime.UtcNow; _exeManager.Create(executor); } catch (Exception e) { RedirectToAction("Index"); } return(RedirectToAction("Index")); }