public ActionResult AddCategory(CategoryMaster U) { if (ModelState.IsValid) { if (TempData["IsEdit"] != null && TempData["IsEdit"] == "1") { U.CategoryID = Convert.ToInt32(TempData["Id"].ToString()); repository.Update(U); repository.Save(); TempData["Message"] = "Record Update Succesfully"; TempData["IsEdit"] = "0"; } else { repository.Insert(U); repository.Save(); TempData["Message"] = "Record Save Succesfully"; TempData["IsEdit"] = "0"; } } else { TempData["Message"] = "All fields are required with *"; } ViewBag.userdetails = repository.GetAll(); return(RedirectToAction("Index")); }
public IActionResult Add([FromBody] CustomerDTO CustomerDTO) { Customer Customer = new Customer(); Customer.name = CustomerDTO.name; Customer.address = CustomerDTO.address; Customer.field = CustomerDTO.field; Customer.sectorid = CustomerDTO.sectorid; Customer.ownerid = CustomerDTO.ownerid; Customer.count = 3; Customer.vacancy = CustomerDTO.vacancy; Customer.email = CustomerDTO.email; Customer.created = DateTime.Now; _CustomerRepo.Insert(Customer); _CustomerRepo.Save(); foreach (var element in CustomerDTO.Phones) { _PhonesRepo.Insert(new Phones() { objectid = Customer.id, objectname = "Customer", phone = element.phone, whatsapp = element.whatsapp }); _PhonesRepo.Save(); } return(Ok(Customer.id)); }
public IActionResult TakeAction([FromBody] OrderDTO order) { var result = _OrderRepositry.GetById(order.id); if (!string.IsNullOrEmpty(order.result) && result != null) { OrderResult orderResult = new OrderResult(); orderResult.orderid = order.id; orderResult.result = order.result; orderResult.useraction = order.useraction; orderResult.createdate = DateTime.Now; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Order").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _OrderResultRepositry.Insert(orderResult); _OrderResultRepositry.Save(); _OrderRepositry.Update(result); _OrderRepositry.Save(); } if (order.Done == true && result != null) { result.Done = order.Done; result.useraction = order.useraction; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Order").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _OrderRepositry.Update(result); _OrderRepositry.Save(); } if (order.late.HasValue && result != null) { if (order.late.Value < DateTime.Now || order.late.Value.Hour < 9 || order.late.Value.Hour > 17) { return(Ok("Invalid Date")); } var difference = (int)(order.late.Value - result.create).TotalHours; result.count = difference; result.useraction = order.useraction; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Order").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _OrderRepositry.Update(result); _OrderRepositry.Save(); } return(Ok(true)); }
public IActionResult Add([FromBody] SectorModel SectorModel) { Sector sector = new Sector(); sector.Name = SectorModel.Name; _SectorRepo.Insert(sector); _SectorRepo.Save(); return(Ok(true)); }
public IActionResult TakeAction([FromBody] CheckDTO Check) { var result = _CheckRepositry.GetById(Check.id); if (!string.IsNullOrEmpty(Check.result) && result != null) { CheckResult CheckResult = new CheckResult(); CheckResult.orderid = Check.id; CheckResult.result = Check.result; CheckResult.useraction = Check.useraction; CheckResult.createdate = DateTime.Now; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _CheckResultRepositry.Insert(CheckResult); _CheckResultRepositry.Save(); _CheckRepositry.Update(result); _CheckRepositry.Save(); } if (Check.Done == true && result != null) { result.Done = Check.Done; result.useraction = Check.useraction; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _CheckRepositry.Update(result); _CheckRepositry.Save(); } if (Check.late.HasValue && result != null) { if (Check.late.Value < DateTime.Now || Check.late.Value.Hour < 9 || Check.late.Value.Hour > 17) { return(Ok("Invalid Date")); } var difference = (int)(Check.late.Value - result.create).TotalHours; result.count = difference; result.useraction = Check.useraction; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _CheckRepositry.Update(result); _CheckRepositry.Save(); } return(Ok(true)); }
public ActionResult AddProduct(ProductDetailsMaster U) { if (ModelState.IsValid) { if (U.ProductID != 0) { repository.Update(U); repository.Save(); return(Json(new { Success = true, Message = "Record Updated sucesfully" }, JsonRequestBehavior.AllowGet)); } else { repository.Insert(U); repository.Save(); return(Json(new { Success = true, Message = "Record Save sucesfully" }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = false, Message = "Error Occured" }, JsonRequestBehavior.AllowGet)); }
public IActionResult Add([FromBody] EmployeeDTO employeeDTO) { Employee employee = new Employee(); employee.customerid = employeeDTO.customerid; employee.email = employeeDTO.email; employee.name = employeeDTO.name; employee.jobtitle = employeeDTO.jobtitle; _EmpRepo.Insert(employee); _EmpRepo.Save(); foreach (var element in employeeDTO.Phones) { _PhonesRepo.Insert(new Phones() { objectid = employee.id, objectname = "Employee", phone = element.phone, whatsapp = element.whatsapp }); _PhonesRepo.Save(); } return(Ok(true)); }
public IActionResult SetLock([FromBody] CustomerLock l) { _LockRepositry.Insert(l); _LockRepositry.Save(); return(Ok()); }
public string AddFollowUp([FromBody] FollowUpDTO followUpDTO) { try { var customer = _CustomerRepo.GetById(followUpDTO.customerid); if (followUpDTO.delay.HasValue) { if (followUpDTO.delay.Value < DateTime.Now || followUpDTO.delay.Value.Hour < 9 || followUpDTO.delay.Value.Hour > 17) { return("Invalid Date"); } if (customer != null) { var difference = (long)(followUpDTO.create - customer.created.AddDays(customer.count).AddHours(customer.hours == null?0:(double)customer.hours)).TotalHours; customer.hours = difference; _CustomerRepo.Update(customer); _CustomerRepo.Save(); var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == followUpDTO.customerid && s.objectname == "FollowUp").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } } } else { FollowUp followUp = new FollowUp(); followUp.create = followUpDTO.create; followUp.customerid = followUpDTO.customerid; followUp.discribtion = followUpDTO.discribtion; followUp.order = followUpDTO.order; followUp.followup = followUpDTO.followup; followUp.ownerid = followUpDTO.ownerid; if (customer != null) { customer.hours = null; customer.count = Time[customer.count]; _CustomerRepo.Update(customer); _CustomerRepo.Save(); _genericRepositry.Insert(followUp); _genericRepositry.Save(); } if (followUp.order) { Order order = new Order(); order.count = 0; order.customerid = customer.id; order.ownerid = followUp.ownerid; order.description = followUp.discribtion; order.create = DateTime.Now; order.Done = false; order.id = 0; _OrderRepositry.Insert(order); _OrderRepositry.Save(); } if (followUp.followup) { Check Check = new Check(); Check.count = 0; Check.customerid = customer.id; Check.ownerid = followUp.ownerid; Check.description = followUp.discribtion; Check.create = DateTime.Now; Check.Done = false; Check.id = 0; _CheckRepositry.Insert(Check); _CheckRepositry.Save(); } var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == followUpDTO.customerid && s.objectname == "FollowUp").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } } return("Added Done"); } catch (Exception e) { return("Error in Add"); } }