Пример #1
0
        public MA_FUNCTIONAL CreateFunction(SessionInfo sessioninfo, MA_FUNCTIONAL function)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_FUNCTIONALRepository.GetAll().FirstOrDefault(p => p.USERCODE.ToLower().Equals(function.USERCODE.ToLower()));
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                unitOfWork.MA_FUNCTIONALRepository.Add(function);
                unitOfWork.Commit();
            }

            return function;
        }
Пример #2
0
 public static object UpdateFunction(SessionInfo sessioninfo, MA_FUNCTIONAL record)
 {
     try
     {
         FunctionBusiness _functionBusiness = new FunctionBusiness();
         record.ID = record.ID;
         record.LABEL = record.LABEL;
         record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE ? false : true;
         record.USERCODE = record.USERCODE;
         var addedStudent = _functionBusiness.UpdateFunction(sessioninfo, record);
         return new { Result = "OK" };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }
Пример #3
0
        public MA_FUNCTIONAL UpdateFunction(SessionInfo sessioninfo, MA_FUNCTIONAL function)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_FUNCTIONALRepository.GetAll().FirstOrDefault(p => p.USERCODE.ToLower().Equals(function.USERCODE.ToLower()) && p.ID != function.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                var foundfunction = unitOfWork.MA_FUNCTIONALRepository.All().FirstOrDefault(p => p.ID == function.ID);
                if (foundfunction == null)
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                else
                {

                    foundfunction.ID = function.ID;
                    foundfunction.LABEL = function.LABEL;
                    foundfunction.ISACTIVE = function.ISACTIVE;
                    foundfunction.USERCODE = function.USERCODE;
                    unitOfWork.Commit();

                }
            }

            return function;
        }
 public static object Update(MA_FUNCTIONAL record)
 {
     return FunctionUIP.UpdateFunction(SessionInfo, record);
 }