Exemple #1
0
        public bool Update(LieuTrinhDTO lieutrinhDto)
        {
            try
            {
                var lieutrinh = _lieutrinhRepository.GetById(lieutrinhDto.MaLieuTrinh);
                // check nhan vien exist
                if (lieutrinh == null)
                {
                    return(false);
                }

                //Update nhan vien detail
                lieutrinh.MaLieuTrinh   = lieutrinhDto.MaLieuTrinh;
                lieutrinh.TenLieuTrinh  = lieutrinhDto.TenLieuTrinh;
                lieutrinh.MoTaLieuTrinh = lieutrinhDto.MoTaLieuTrinh;
                lieutrinh.STT           = Convert.ToInt32(lieutrinhDto.STT);
                lieutrinh.MaThuoc       = lieutrinhDto.MaThuoc;


                // update user
                _lieutrinhRepository.Update(lieutrinh);
                _unitOfWork.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public async Task <BaseResponse> Update(LieuTrinhDTO lieutrinhDTO)
 {
     try
     {
         var result = _lieutrinhService.Update(lieutrinhDTO);
         if (result)
         {
             return(await Task.FromResult(new BaseResponse(result)));
         }
         return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false));
     }
 }
 public async Task <BaseResponse> Create(LieuTrinhDTO lieutrinhDto)
 {
     try
     {
         var result = _lieutrinhService.Create(lieutrinhDto);
         if (result)
         {
             return(await Task.FromResult(new BaseResponse(result)));
         }
         return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess)));
     }
     catch (Exception e)
     {
         return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess)));
     }
 }
Exemple #4
0
        public bool Create(LieuTrinhDTO lieutrinhDto)
        {
            try
            {
                //var item = CheckExistsTenLieuTrinh(lieutrinhDto.TenLieuTrinh);
                //if (item) return false;
                var lieutrinh = new LieuTrinh
                {
                    MaLieuTrinh   = Guid.NewGuid(),
                    TenLieuTrinh  = lieutrinhDto.TenLieuTrinh,
                    MoTaLieuTrinh = lieutrinhDto.MoTaLieuTrinh,
                    MaThuoc       = lieutrinhDto.MaThuoc,
                    STT           = Convert.ToInt32(lieutrinhDto.STT)
                };

                _lieutrinhRepository.Insert(lieutrinh);
                _unitOfWork.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }