Exemplo n.º 1
0
        public ServiceVerboseDto Create(CreateServiceDto newService, int orderID)
        {
            newService.ValidateData();
            var service = newService.ToEntity();

            service.OrderID = orderID;
            _dbContext.Service.Add(service);
            _dbContext.SaveChanges();

            return(service.ToVerboseDto());
        }
Exemplo n.º 2
0
        public IActionResult Create([Required][FromBody] CreateServiceDto service, [FromRoute] int orderID)
        {
            try
            {
                var result = _repo.Create(service, orderID);

                return(StatusCode((int)HttpStatusCode.Created, result));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 3
0
        public async Task <ServiceDto> UpdateAsync(Guid id, CreateServiceDto input)
        {
            var service = await _serviceRepository.GetAsync(id);

            //service.Code = input.Code;
            service.SetName(input.Name);
            service.SetType(input.Type);
            service.SetCategory(input.Category);
            service.SetDescription(input.Description);
            service.SetLiveMode(input.LiveMode);
            service.SetMetaData(input.Metadata.ToString());
            service.SetProductImage(input.ProductImage);

            return(ObjectMapper.Map <Service, ServiceDto>(service));
        }
Exemplo n.º 4
0
        public async Task <bool> UpdateService(CreateServiceDto service, Guid uuid)
        {
            var request  = JsonConvert.SerializeObject(service);
            var response = await HttpClient.PutAsync(string.Format(BusinessmanServiceUri, uuid), new StringContent(request, Encoding.UTF8, ApplicationJson));

            var json = await response.Content.ReadAsStringAsync();

            Debug.WriteLine(json);
            var data = JsonConvert.DeserializeObject <ResponseDto <object> >(json);

            if (data.Success)
            {
                MyServicesListChanged?.Invoke(this, EventArgs.Empty);
            }
            return(data.Success);
        }
Exemplo n.º 5
0
        public static void ValidateData(this CreateServiceDto dto)
        {
            var errors = new StringBuilder();

            // ServiceDate
            errors.AddIfExists(dto.ServiceDate.ValidateFutureDate(ValidationMessages.ServiceDateValid));
            // ServiceDescription
            errors.AddIfExists(dto.ServiceDescription.ValidateRequired(ValidationMessages.ServiceDescriptionRequired));
            errors.AddIfExists(dto.ServiceDescription.ValidateLength(400, ValidationMessages.ServiceDescriptionLength));
            // Price
            errors.AddIfExists(dto.Price.ValidatePositiveDecimal(ValidationMessages.PriceRequired));

            if (errors.Length > 0)
            {
                throw new ValidationException(errors.ToString());
            }
        }
Exemplo n.º 6
0
        public async Task <bool> CreateService(CreateServiceDto createServiceDto)
        {
            var request  = JsonConvert.SerializeObject(createServiceDto);
            var response = await HttpClient.PostAsync(BusinessmanServicesUri, new StringContent(request, Encoding.UTF8, ApplicationJson));

            var json = await response.Content.ReadAsStringAsync();

            Debug.WriteLine(json);
            if (string.IsNullOrEmpty(json))
            {
                return(false);
            }
            var data = JsonConvert.DeserializeObject <ResponseDto <object> >(json);

            if (data.Success)
            {
                MyServicesListChanged?.Invoke(this, EventArgs.Empty);
            }
            return(data.Success);
        }
Exemplo n.º 7
0
 public static Service ToEntity(this CreateServiceDto dto)
 {
     Init();
     return(Mapper.Map <Service>(dto));
 }
Exemplo n.º 8
0
 public Task <bool> CreateServiceDto(CreateServiceDto ServiceDto)
 {
     throw new System.NotImplementedException();
 }
 public async Task <ServiceDto> Createservice(CreateServiceDto input)
 {
     return(await _serviceAppService.CreateAsync(input));
 }