示例#1
0
        /// <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));
        }
示例#2
0
        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);
        }
示例#3
0
        public int Add(ServiceType dto)
        {
            Model model = new Model()
            {
                Description = dto.Description
            };

            return(_repository.Add(model));
        }
示例#4
0
        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"));
        }
示例#6
0
 public void CreateServiceType(ServiceType ServiceType)
 {
     _repository.Add(ServiceType);
 }