示例#1
0
 public IActionResult Create(Service service)
 {
     service.Message = "";
     if (ModelState.IsValid)
     {
         _serviceRepo.Create(service);
         return(View("Services", GetList()));
     }
     return(View(service));
 }
        public async Task <IActionResult> Post([FromBody] ServiceRegister s)
        {
            if (ModelState.IsValid)
            {
                var service = await repository.Create(new Service
                {
                    Name            = s.Name,
                    Code            = s.Code,
                    Cost            = s.Cost,
                    UnitMeasurement = s.UnitMeasurement,
                    NeedPlate       = s.NeedPlate,
                    EmissionPoint   = await ePointRepository.GetPoint(s.EmissionPoint),
                    IsActive        = s.IsActive
                });

                return(Json(new StandardResponse
                {
                    Status = 200,
                    Data = service
                }));
            }
            else
            {
                var errorList = ModelState.Values.SelectMany(v => v.Errors);
                var errors    = errorList.Select(e => e.ErrorMessage).ToArray();
                return(Json(new StandardResponse
                {
                    Status = 400,
                    Errors = errors
                }));
            }
        }
示例#3
0
        public async Task <ServiceResponse> Create(ServiceDTO newService)
        {
            var service = ServiceMapper.Map(newService);

            if (service.Name == null)
            {
                string errorMessage1 = "Service name not found.";
                Log.Error(errorMessage1);
                return(new ServiceResponse(errorMessage1));
            }
            if (service.Description == null)
            {
                string errorMessage2 = "Service description not found.";
                Log.Error(errorMessage2);
                return(new ServiceResponse(errorMessage2));
            }
            try
            {
                await _serviceRepository.Create(service);

                await _context.SaveChangesAsync();

                return(new ServiceResponse(ServiceMapper.Map(service)));
            }
            catch (Exception exception)
            {
                string errorMessage = $"An error occured when creating the item: {exception.Message}";
                return(new ServiceResponse(errorMessage));
            }
        }
示例#4
0
        public async Task <IActionResult> Create([FromBody] ServiceCreateDTO serviceDTO)
        {
            try
            {
                if (serviceDTO == null)
                {
                    return(BadRequest(ModelState));
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var service   = _mapper.Map <Service>(serviceDTO);
                var isSuccess = await _serviceRepository.Create(service);

                if (!isSuccess)
                {
                    return(InternalError($"Creation failed"));
                }
                return(Created("Create", new { service }));
            }
            catch (Exception e)
            {
                return(InternalError($"{e.Message} - {e.InnerException}"));
            }
        }
示例#5
0
 public ServiceCreateDto Create(ServiceCreateDto service)
 {
     if (service != null)
     {
         var serv = new Clinic.System.Entities.Models.Service();
         serv.Name  = service.Name;
         serv.Price = service.Price;
         _serviceRepository.Create(serv);
         _unitOfWork.Complete();
     }
     return(service);
 }
        public Service Create(CreateServiceCommand command)
        {
            var service = new Service(command.Name, command.Value, command.CoachingProcess, command.Description);

            service.Validate();
            _repository.Create(service);

            if (Commit())
            {
                return(service);
            }

            return(null);
        }
        public async Task <bool> CreateService(Service service)
        {
            try
            {
                _serviceRepository.Create(service);
                await _serviceRepository.SaveAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
示例#8
0
 public JsonResult Create(ServiceRequest model)
 {
     try
     {
         ///ServiceRequest serviceRequest = Mapper.Map<ServiceRequestViewModel, ServiceRequest>(model);
         model.CreatedDate = DateTime.Now;
         model.CreatedBy   = CurrentUser.UserId;
         _repository.Create(model);
         return(Json("success", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message, JsonRequestBehavior.AllowGet));
     }
 }
 public Service Create(Service model)
 {
     _repository.Create(model);
     _repository.SaveCganges();
     return(model);
 }
示例#10
0
 public async Task <RepositoryResponce> Create(TEntity entity) => await _ServiceRepository.Create(CombineUrl(), entity);
        public ActionResult PostService([FromBody] ServiceCreateDto dto)
        {
            var entity = _repository.Create(dto);

            return(Ok(entity));
        }
示例#12
0
 public void Create(Service entity)
 {
     _servicerepository.Create(entity);
 }
示例#13
0
 public async Task <Service> Create(Service service)
 {
     return(await _serviceRepository.Create(service));
 }
示例#14
0
        public ActionResult <ApiResultModel <UtService> > Create([FromForm] string name, [FromForm] string phone)
        {
            var row = _serviceRepository.Create(name, phone);

            return(Ok(new ApiResultModel <UtService>(200, row)));
        }
示例#15
0
 public virtual async Task <ApiResult <TSelectDto> > Create(TDto dto, CancellationToken cancellationToken)
 {
     dto.CreatedDate = DateTime.Now;
     return(await serviceRepository.Create(dto, cancellationToken));
 }
 /// <summary>
 /// Adds the service.
 /// </summary>
 /// <param name="service">The service.</param>
 public void AddService(Service service)
 {
     serviceRepository.Create(service);
 }
示例#17
0
 public Service Create(Service service)
 {
     return(_serviceRepository.Create(service));
 }