public MA_COUNTRY Create(SessionInfo sessioninfo, MA_COUNTRY country) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate1 = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.LABEL == country.LABEL); if (checkDuplicate1 != null) { throw this.CreateException(new Exception(), "Short name is duplicated"); } //Prepare Country-Limit data MA_COUNTRY_LIMIT ctLimit = new MA_COUNTRY_LIMIT(); ctLimit.ID = Guid.NewGuid(); ctLimit.COUNTRY_ID = country.ID; ctLimit.AMOUNT = 0; ctLimit.EFFECTIVE_DATE = sessioninfo.Process.CurrentDate; ctLimit.EXPIRY_DATE = sessioninfo.Process.CurrentDate; ctLimit.ISACTIVE = true; ctLimit.ISTEMP = false; ctLimit.FLAG_CONTROL = true; ctLimit.LOG.INSERTDATE = DateTime.Now; ctLimit.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId; unitOfWork.MA_COUNTRYRepository.Add(country); unitOfWork.MA_COUNTRY_LIMITRepository.Add(ctLimit); unitOfWork.Commit(); } return(country); }
public MA_COUNTRY Update(SessionInfo sessioninfo, MA_COUNTRY country) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { var checkDuplicate1 = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.LABEL == country.LABEL && p.ID != country.ID); if (checkDuplicate1 != null) { throw this.CreateException(new Exception(), "Short name is duplicated"); } var foundData = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.ID == country.ID); if (foundData == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { foundData.LABEL = country.LABEL; foundData.DESCRIPTION = country.DESCRIPTION; unitOfWork.Commit(); } } return(country); }
public static object Update(SessionInfo sessioninfo, MA_COUNTRY record) { try { CountryBusiness _countryBusiness = new CountryBusiness(); record.LABEL = record.LABEL.ToUpper(); record.DESCRIPTION = record.DESCRIPTION.ToUpper(); var updateRecord = _countryBusiness.Update(sessioninfo, record); return(new { Result = "OK", Record = updateRecord }); } catch (Exception ex) { return(new { Result = "ERROR", Message = ex.Message }); } }
public static object Update(MA_COUNTRY record) { return(CountryUIP.Update(SessionInfo, record)); }