public bool Create(PotentialDistributor pDis) { logger.Info("Start Create potential distributor method"); try { _pdistributorRepository.Add(pDis); _unitOfWork.SaveChange(); } catch (Exception ex) { logger.Info("Status: Fail + " + ex.Message); return(false); } logger.Info("Status: Success"); return(true); }
public bool UpdateStatus(int id, byte status, string note) { logger.Info("Start update status of potential distributor..."); try { PotentialDistributor pDis = GetPDistributor(id); pDis.status = status; pDis.note = note; _pdistributorRepository.Update(pDis); _unitOfWork.SaveChange(); logger.Info("Status: Success"); return(true); } catch (Exception ex) { logger.Info("Status: Fail + " + ex.Message); return(false); } }
public ActionResult Create(CreatePDistributorViewModel model) { logger.Info("Start Create(POST) - PDistributorController"); var pDis = new PotentialDistributor { idDistributor = _pdistributorService.GeneratePDistributorId(), name = model.name, address = model.address, Email = model.Email, phone = model.phone, createdDate = DateTime.Now, status = 0, }; var rep = new Representative { idRepresentative = _representativeService.GenerateRepresentativeId(), name = model.rep_name, email = model.rep_email, title = model.title, phone = model.rep_phone, PDistributor = pDis.idDistributor, }; var result = _pdistributorService.Create(pDis, rep); if (result == true) { logger.Info("Success: Complete Create(POST) - PDistributorController"); TempData["success"] = "Thành công"; return(RedirectToAction("Create")); } else { logger.Info("Fail: Create(POST) - PDistributorController"); TempData["fail"] = result; return(View(model)); } }