예제 #1
0
        public async Task <int> Xoa(int id)
        {
            TienIchMoRong_CongTy tienichmorong_congty = _context.TienIchMoRong_CongTys.Where(a => a.ID_TienIchMoRong == id).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.Delete = true;
            _context.TienIchMoRong_CongTys.Update(tienichmorong_congty);
            await _context.SaveChangesAsync();

            return(tienichmorong_congty.ID_TienIchMoRong);
        }
예제 #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);
        }