예제 #1
0
        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;
        }
예제 #2
0
        public static object Create(SessionInfo sessioninfo, MA_COUNTRY record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();

                record.ID = Guid.NewGuid();
                record.LABEL = record.LABEL.ToUpper();
                record.DESCRIPTION = record.DESCRIPTION.ToUpper();

                var addedRecord = _countryBusiness.Create(sessioninfo, record);

                return new { Result = "OK", Record = addedRecord };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
예제 #3
0
        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;
        }