public FirstMigration() { using (ApplicationContext db = new ApplicationContext()) { Executor executor1 = new Executor() { Price = 200, DateTime = DateTime.Now, UserId = "3d4f6039-773d-4c3a-a727-cca8ff3407e8" }; Executor executor2 = new Executor() { Price = 300, DateTime = DateTime.Now, UserId = "6171483a-a5be-415f-a7cc-02df0e49c7b8" }; Executor executor3 = new Executor() { Price = 400, DateTime = DateTime.Now, UserId = "dc61eddc-313f-4570-8fce-629d31e92343" }; Executor executor4 = new Executor() { Price = 500, DateTime = DateTime.Now, UserId = "e504fe16-ffcb-4e00-9626-ba576dc47316" }; ServiceIndustryType typeAuto = new ServiceIndustryType() { Name = "Auto", ServiceIndustryTypePhoto = "auto.png" }; ServiceIndustryType typeIt = new ServiceIndustryType() { Name = "It", ServiceIndustryTypePhoto = "it.png" }; ServiceIndustry service = new ServiceIndustry() { Name = "Wehl change", Description = "Change KALESo", Executors = new List <Executor>() { executor1, executor2 }, ServiceIndustryType = typeAuto }; ServiceIndustry service2 = new ServiceIndustry() { Name = "It change baterry", Description = "Change battery", Executors = new List <Executor>() { executor3, executor4 }, ServiceIndustryType = typeIt }; db.Executors.AddRange(new List <Executor>() { executor1, executor2, executor3, executor4 }); db.ServiceIndustryTypes.AddRange(new List <ServiceIndustryType>() { typeAuto, typeIt }); db.ServiceIndustries.AddRange(new List <ServiceIndustry>() { service, service2 }); db.SaveChanges(); } }
public ActionResult Edit(ServiceIndustry serviceIndustry) { if (ModelState.IsValid) { repository.Update(serviceIndustry); return(RedirectToAction("Index", "ServiceIndustryType")); } SetTypeViewBag(serviceIndustry.ServiceIndustryTypeId); return(View(serviceIndustry)); }
public bool Update(ServiceIndustry ser) { try { _unitOfWork.ServRepos.Update(ser); _unitOfWork.Save(); return(true); } catch (Exception e) { } return(false); }
public bool Create(ServiceIndustry service) { try { _unitOfWork.ServRepos.Insert(service); _unitOfWork.Save(); return(true); } catch (Exception e) { throw new Exception(e.Message); } return(false); }
public ActionResult CreatePost(ServiceIndustry serviceIndustry) { try { ServiceIndustryType serviceIndustryType = _servTypeManager.GetAll().Find(s => s.Name == serviceIndustry.serviceIndustryType.Name); serviceIndustry.ServiceIndustryId = Guid.NewGuid().ToString(); serviceIndustry.ServiceIndustryTypeId = serviceIndustryType.ServiceIndustryTypeId; serviceIndustry.serviceIndustryType = serviceIndustryType; _servManager.Create(serviceIndustry); } catch (Exception e) { RedirectToAction("Index"); } return(RedirectToAction("Index")); }
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")); }
public ActionResult Edit(ServiceIndustry serviceIndustry) { serviceIndustry.serviceIndustryType = _servTypeManager.GetById(serviceIndustry.ServiceIndustryTypeId); _servManager.Update(serviceIndustry); return(RedirectToAction("Index")); }