Пример #1
0
        public string UpdateCustomerPofile(CustomerRowViewModel model)
        {
            var existedCustomer = _customerRepository.Get(x => x.Username.Equals(model.Username, StringComparison.OrdinalIgnoreCase));

            if (existedCustomer == null)
            {
                return("Not found customer");
            }

            if (model.FullName != null && !model.FullName.Equals(""))
            {
                existedCustomer.FullName = model.FullName;
            }
            if (model.Email != null && !model.Email.Equals(""))
            {
                existedCustomer.Email = model.Email;
            }
            if (model.Address != null && !model.Address.Equals(""))
            {
                existedCustomer.Address = model.Address;
            }
            existedCustomer.UpdatedAtUTC = DateTime.UtcNow;
            existedCustomer.IsActive     = true;
            _customerRepository.Update(existedCustomer);
            try
            {
                _unitOfWork.CommitChanges();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(string.Empty);
        }
Пример #2
0
        public ActionResult UpdateProfileCustomer(CustomerRowViewModel model)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest("Invalid Request");
            //}

            var updateResult = _customerService.UpdateCustomerPofile(model);

            if (!string.IsNullOrEmpty(updateResult))
            {
                return(StatusCode((int)HttpStatusCode.NotAcceptable, updateResult));
            }
            return(Ok());
        }
Пример #3
0
        public string UpdateCustomerAuthen(CustomerRowViewModel model)
        {
            var existedCustomer = _customerRepository.Get(x => x.Id == model.Id);

            if (existedCustomer == null)
            {
                return("Not found customer");
            }

            existedCustomer.IsActive = model.IsActive;
            _customerRepository.Update(existedCustomer);
            try
            {
                _unitOfWork.CommitChanges();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(string.Empty);
        }