/// <summary> /// Add / Update Service Type /// </summary> public ServiceType SaveServiceType(ServiceType serviceType) { ServiceType dbVersion = serviceTypeRepository.Find((int)serviceType.ServiceTypeId); //Code Duplication Check if (serviceTypeRepository.ServiceTypeCodeDuplicationCheck(serviceType)) { throw new CaresException(Resources.Pricing.ServiceType.ServiceTypeCodeDupliationError); } if (dbVersion != null) { UpdateServiceTypePropertie(serviceType, dbVersion); serviceTypeRepository.Update(dbVersion); } else { dbVersion = new ServiceType(); SetServiceTypeProperties(serviceType, dbVersion); serviceTypeRepository.Add(dbVersion); } serviceTypeRepository.SaveChanges(); // To Load the proprties return(serviceTypeRepository.Find(dbVersion.ServiceTypeId)); }
public void ServiceTypeServiceAddAreEqual() { A.CallTo(() => _repository.Add(null)).WithAnyArguments().Returns(42); _service = new ServiceTypeService(_repository); var newId = _service.Add(new Business.DTOs.ServiceType()); Assert.AreEqual(42, newId); }
public int Add(ServiceType dto) { Model model = new Model() { Description = dto.Description }; return(_repository.Add(model)); }
public async Task <IActionResult> CreateServiceType([FromBody] SaveServiceTypeResource resource) { if (!ModelState.IsValid) { return(BadRequest()); } var st = _mapper.Map <SaveServiceTypeResource, ServiceType>(resource); _repository.Add(st); await _unitOfWork.CompleteAsync(); var result = _mapper.Map <ServiceType, SaveServiceTypeResource>(st); return(Ok(result)); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (ServiceType.Category == null) { TempData[SD.Error] = "No puede haber valores en blanco"; return(Page()); } if (ServiceType.Descripcion == null) { TempData[SD.Error] = "No puede haber valores en blanco"; return(Page()); } TempData[SD.Success] = "Tipo de servicio fue creado correctamente"; _ServiceTypeRepo.Add(ServiceType); _ServiceTypeRepo.Save(); return(RedirectToPage("./IndexServiceType")); }
public void CreateServiceType(ServiceType ServiceType) { _repository.Add(ServiceType); }