public IActionResult RegisterTblAccGroup([FromBody] TblAccountGroup tblAccGrp) { if (tblAccGrp == null) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = $"{nameof(tblAccGrp)} can not be null" })); } try { TblAccountGroup result = new GLHelper().RegisterTblAccGroup(tblAccGrp); if (result != null) { return(Ok(new APIResponse() { status = APIStatus.PASS.ToString(), response = result })); } return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Registration failed." })); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public TblAccountGroup RegisterTblAccGroup(TblAccountGroup tblAccGroup) { try { using Repository <TblAccountGroup> repo = new Repository <TblAccountGroup>(); var record = repo.TblAccountGroup.OrderByDescending(x => x.ExtraDate).FirstOrDefault(); if (record != null) { tblAccGroup.AccountGroupId = Convert.ToDecimal(CommonHelper.IncreaseCode(record.AccountGroupId.ToString())); } else { tblAccGroup.AccountGroupId = 1; } tblAccGroup.ExtraDate = DateTime.Now; tblAccGroup.IsDefault = false; repo.TblAccountGroup.Add(tblAccGroup); if (repo.SaveChanges() > 0) { return(tblAccGroup); } return(null); } catch { throw; } }
public TblAccountGroup UpdateTblAccountGroup(TblAccountGroup tblAccGrp) { try { using Repository <TblAccountGroup> repo = new Repository <TblAccountGroup>(); tblAccGrp.ExtraDate = DateTime.Now; tblAccGrp.IsDefault = false; repo.TblAccountGroup.Update(tblAccGrp); if (repo.SaveChanges() > 0) { return(tblAccGrp); } return(null); } catch { throw; } }