예제 #1
0
        public async Task <bool> UpdateAsync(CourierUpdateModel model)
        {
            if (model == null || model.Id <= 0)
            {
                return(ToResponse(false, "Dữ liệu không hợp lệ"));
            }
            if (string.IsNullOrWhiteSpace(model.CustomerName))
            {
                return(ToResponse(false, "Tên khách hàng không được để trống"));
            }
            if (model.AssignId <= 0)
            {
                return(ToResponse(false, "Vui lòng chọn courier"));
            }
            var existProfile = await _rpCourier.GetByIdAsync(model.Id);

            if (existProfile == null)
            {
                return(ToResponse(false, "Hồ sơ không tồn tại"));
            }
            bool isAdmin = _process.User.RoleCode == "admin" ? true :false;

            if (existProfile.Status == (int)ProfileStatus.Cancel)
            {
                if (!isAdmin)
                {
                    return(ToResponse(false, "Bạn không có quyền, vui lòng liên hệ Admin"));
                }
            }
            var profile = _mapper.Map <CourierSql>(model);

            profile.UpdatedBy = _process.User.Id;
            var response = await _rpCourier.UpdateAsync(profile);

            return(ToResponse(response));
        }
예제 #2
0
        public async Task <IActionResult> UpdateAsync([FromBody] CourierUpdateModel model)
        {
            var result = await _bizCourier.UpdateAsync(model);

            return(ToResponse(result));
        }