Пример #1
0
        public async Task <IActionResult> Update([FromRoute] int id, [FromBody] Salon salon)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != salon.Id)
            {
                ModelState.AddModelError(nameof(salon.Id), Translation.IdMismatch);
                return(BadRequest(ModelState));
            }

            try
            {
                await salonRepository.Update(salon);

                await salonRepository.SaveChanges();
            }
            catch (Exception ex)
            {
                if (!salonRepository.Exist(id))
                {
                    return(NotFound());
                }
                log.LogError("[POST: PUT: api/Salon/{0}] {1}", id, ex.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }

            return(NoContent());
        }
Пример #2
0
        public CustomerModel Update(int id, CustomerModel customer)
        {
            try
            {
                CustomerEntity customerSelected = _salonManager.GetSingle(id);


                CustomerEntity customerToUpdate = new CustomerEntity
                {
                    FirstName   = customer.FirstName,
                    LastName    = customer.LastName,
                    PhoneNumber = customer.PhoneNumber,
                    Email       = customer.Email
                };

                CustomerEntity updatedCustomer = _salonManager.Update(id, customerToUpdate);


                CustomerModel customerViewModel = new CustomerModel
                {
                    FirstName   = updatedCustomer.FirstName,
                    LastName    = updatedCustomer.LastName,
                    PhoneNumber = updatedCustomer.PhoneNumber,
                    Email       = updatedCustomer.Email
                };

                return(customerViewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #3
0
        public ServiceModel Update(int id, ServiceModel service)
        {
            try
            {
                ServiceEntity serviceSelected = _salonManager.GetSingle(id);

                ServiceEntity serviceToUpdate = new ServiceEntity
                {
                    NameOfService = service.NameOfService,
                    Price         = service.Price
                };

                ServiceEntity updatedService = _salonManager.Update(id, serviceToUpdate);


                ServiceModel serviceViewModel = new ServiceModel
                {
                    NameOfService = updatedService.NameOfService,
                    Price         = updatedService.Price
                };

                return(serviceViewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #4
0
 public void UpdateProfile(SalonViewModel model)
 {
     if (model != null)
     {
         var salon = _salonRepository.FindById(model.SalonId);
         if (salon != null)
         {
             salon.Name    = model.Name;
             salon.Phone   = model.Phone;
             salon.Address = model.Address;
             _salonRepository.Update(salon);
             _unitOfWork.Save();
         }
     }
 }
Пример #5
0
        public void Update(int id, GlobalModel order)
        {
            try
            {
                OrderEntity customerSelected = _orderManager.GetSingle(id);

                OrderEntity orderToUpdate = new OrderEntity
                {
                    ServiceId       = order.ServiceId,
                    CustomerId      = order.CustomerId,
                    DateOfProcedure = order.Date,
                    StatusId        = order.StatusId,
                };

                OrderEntity updatedOrder = _orderManager.Update(id, orderToUpdate);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #6
0
        public ResultModel <Salon> SalonUpdate(Salon model)
        {
            SalonValidator   validator = new SalonValidator();
            ValidationResult result    = validator.Validate(model);

            if (result.IsValid)
            {
                _salonRepository.Update(model, model.SalonID);
                return(new ResultModel <Salon>
                {
                    Errors = null,
                    IsValid = true,
                    Message = "Update Başarılı"
                });
            }
            return(new ResultModel <Salon>
            {
                Errors = result.Errors.Select(x => x.ErrorMessage).ToList(),
                IsValid = false,
                Message = "Update Başarısız"
            });
        }