Пример #1
0
        public MA_PCCF_CONFIG UpdateConfig(SessionInfo sessioninfo, MA_PCCF_CONFIG data)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PCCF_CONFIGRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(data.LABEL.ToLower()) && p.ID != data.ID);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                var found = unitOfWork.MA_PCCF_CONFIGRepository.All().FirstOrDefault(p => p.ID == data.ID);
                if (found == null)
                {
                    throw this.CreateException(new Exception(), "Data not found!");
                }
                else
                {
                    found.ID                 = data.ID;
                    found.ISACTIVE           = data.ISACTIVE;
                    found.DESCRIPTION        = data.DESCRIPTION;
                    found.LABEL              = data.LABEL;
                    found.PCCF_ID            = data.PCCF_ID;
                    found.PRODUCT_ID         = data.PRODUCT_ID;
                    found.PRIORITY           = data.PRIORITY;
                    found.LOG.MODIFYBYUSERID = data.LOG.MODIFYBYUSERID;
                    found.LOG.MODIFYDATE     = data.LOG.MODIFYDATE;
                    unitOfWork.Commit();
                }
            }

            return(data);
        }
Пример #2
0
        public MA_PCCF_CONFIG CreateConfig(SessionInfo sessioninfo, MA_PCCF_CONFIG data)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PCCF_CONFIGRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(data.LABEL.ToLower()));
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                unitOfWork.MA_PCCF_CONFIGRepository.Add(data);
                unitOfWork.Commit();
            }

            return(data);
        }
Пример #3
0
        public static object UpdateConfig(SessionInfo sessioninfo, MA_PCCF_CONFIG record)
        {
            try
            {
                LoggingHelper.Debug("Update Config by " + record.LABEL);

                PCCFConfigBusiness _factorBusiness = new PCCFConfigBusiness();
                record.ISACTIVE           = record.ISACTIVE == null || !record.ISACTIVE.Value ? false : true;
                record.LABEL              = record.LABEL.ToUpper();
                record.DESCRIPTION        = record.DESCRIPTION.ToUpper();
                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;
                var updated = _factorBusiness.UpdateConfig(sessioninfo, record);
                LoggingHelper.Debug("End Update");
                return(new { Result = "OK" });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #4
0
 public static object UpdateConfig(MA_PCCF_CONFIG record)
 {
     return(PCCFConfigUIP.UpdateConfig(SessionInfo, record));
 }