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)); }
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); }
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); }
public async Task <IActionResult> Sua([FromForm] TienIchMoRong_CongTyRequest tienichmorong_congtyrequest) { var test = await _tienichmorong_congtyservice.Sua(tienichmorong_congtyrequest); return(Ok(test)); }