예제 #1
0
        public async Task <IActionResult> ThemMoi([FromForm] TienIchMoRong_CongTyRequest tienichmorong_congtyrequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var test = await _tienichmorong_congtyservice.Them(tienichmorong_congtyrequest);

            //validator = new LoaiPhongRequestValidator();
            return(Ok(test));
        }
예제 #2
0
        public async Task <int> Them(TienIchMoRong_CongTyRequest model)
        {
            TienIchMoRong_CongTy tienichmorong_congty = new TienIchMoRong_CongTy();

            tienichmorong_congty.ModifyBy         = model.ModifyBy;
            tienichmorong_congty.CreateBy         = model.CreateBy;
            tienichmorong_congty.Delete           = model.Delete;
            tienichmorong_congty.ID_CongTy        = model.ID_CongTy;
            tienichmorong_congty.ID_TienIchMoRong = model.ID_TienIchMoRong;
            tienichmorong_congty.TenTienich       = model.TenTienich;
            tienichmorong_congty.TrangThai        = model.TrangThai;
            tienichmorong_congty.CreateDate       = DateTime.Now;
            _context.TienIchMoRong_CongTys.Add(tienichmorong_congty);
            await _context.SaveChangesAsync();

            return(tienichmorong_congty.ID_TienIchMoRong);
        }
예제 #3
0
        public async Task <int> Sua(TienIchMoRong_CongTyRequest model)
        {
            TienIchMoRong_CongTy tienichmorong_congty = _context.TienIchMoRong_CongTys.Where(a => a.ID_TienIchMoRong == model.ID_TienIchMoRong).FirstOrDefault();

            if (tienichmorong_congty == null)
            {
                throw new Exception("Tiên ích mở rộng của công ty không tồn tại");
            }
            tienichmorong_congty.ModifyBy         = model.ModifyBy;
            tienichmorong_congty.CreateBy         = model.CreateBy;
            tienichmorong_congty.Delete           = model.Delete;
            tienichmorong_congty.ID_CongTy        = model.ID_CongTy;
            tienichmorong_congty.ID_TienIchMoRong = model.ID_TienIchMoRong;
            tienichmorong_congty.TenTienich       = model.TenTienich;
            tienichmorong_congty.TrangThai        = model.TrangThai;
            tienichmorong_congty.LastModifiedDate = DateTime.Now;
            _context.TienIchMoRong_CongTys.Update(tienichmorong_congty);
            await _context.SaveChangesAsync();

            return(tienichmorong_congty.ID_TienIchMoRong);
        }
예제 #4
0
        public async Task <IActionResult> Sua([FromForm] TienIchMoRong_CongTyRequest tienichmorong_congtyrequest)
        {
            var test = await _tienichmorong_congtyservice.Sua(tienichmorong_congtyrequest);

            return(Ok(test));
        }