public void Create(ServiceChargeModel model) { try { if (_serviceChargeRepository.NameExist(model)) { throw new Exception("Service Charge Already Exists!"); } //var serviceCharge = new ServiceCharge() //{ // Name = model.Name, // Amount = model.Amount, // IsCompulsory = model.IsCompulsory, // TotalAmountPaid = 0, // DateCreated = model.DateCreated, // DueDay = model.DueDay, // DueMonth = model.DueMonth //}; var serviceCharge = Mapper.Map <ServiceChargeModel, ServiceCharge>(model); serviceCharge.DateCreated = DateTime.Now; if (model.BuildingModelIds.Any()) { serviceCharge.BuildingIds = string.Join(",", model.BuildingModelIds); } _serviceChargeRepository.Insert(serviceCharge); } catch (Exception) { throw; } }
public void Update(ServiceChargeModel model) { try { if (_serviceChargeRepository.NameExist(model)) { throw new Exception("Service Charge Already Exists"); } var serviceCharge = _serviceChargeRepository.Find(model.Id); if (serviceCharge == null) { throw new Exception("Service Charge not found"); } //serviceCharge.Name = model.Name; //serviceCharge.Amount = model.Amount; //serviceCharge.DateCreated = model.DateCreated; //serviceCharge.IsCompulsory = model.IsCompulsory; //serviceCharge.DueDay = model.DueDay; //serviceCharge.DueMonth = model.DueMonth; Mapper.Map(model, serviceCharge); _serviceChargeRepository.Update(serviceCharge); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void Create(ServiceChargeModel model) { try { if (_serviceChargeRepository.NameExist(model)) { throw new ArgumentException("Service CHarge Already Exists!"); } var serviceCharge = new ServiceCharge() { Name = model.Name, Amount = model.Amount, IsCompulsory = model.IsCompulsory, TotalAmountPaid = 0, DateCreated = model.DateCreated, DueDay = model.DueDay, DueMonth = model.DueMonth }; if (model.BuildingModelIds.Any()) { serviceCharge.BuildingIds = string.Join(",", model.BuildingModelIds); } _serviceChargeRepository.Insert(serviceCharge); } catch (Exception) { throw; } }
public ActionResult AddServiceCharge() { ServiceChargeModel scm = new ServiceChargeModel(); scm.DeviceCategoryList = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text"); scm.DeviceSubCategoryList = new SelectList(Enumerable.Empty <SelectListItem>()); scm.BrandList = new SelectList(dropdown.BindBrand(CurrentUser.CompanyId), "Value", "Text"); scm.ModelNameList = new SelectList(Enumerable.Empty <SelectListItem>()); return(View(scm)); }
public ActionResult AddServiceCharge(ServiceChargeModel model) { try { if (ModelState.IsValid) { using (var con = new SqlConnection(_connectionString)) { var CurrentUser = Session["User"] as SessionModel; var result = con.Query <int>("Add_Edit_Delete_ServiceCharge", new { model.ServiceChargeId, model.CategoryId, model.SubCatId, model.BrandId, ModelName = model.ModalNameId, HSN = model.HSNCode, model.SAC, model.TRUPC, model.Form, model.MRP, model.MarketPrice, model.ServiceCharge, model.IsActive, User = CurrentUser.UserId, Action = "I" }, commandType: CommandType.StoredProcedure).FirstOrDefault(); var response = new ResponseModel { IsSuccess = false }; if (result == 1) { response.IsSuccess = true; response.Response = "Submitted Successfully"; TempData["response"] = response; } else { response.IsSuccess = false; response.Response = "Something Went Wrong"; TempData["response"] = response; } } return(RedirectToAction("ServiceCharge")); } } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("ServiceCharge")); }
public IHttpActionResult Put(ServiceChargeModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _serviceChargeService.Update(model); return(Ok(model)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public bool NameExist(ServiceChargeModel model) { return(Table.Any(c => c.Id != model.Id && model.Name.Equals(c.Name, StringComparison.OrdinalIgnoreCase))); }