Example #1
0
        public MA_LIMIT_PRODUCT UpdateLimitProduct(SessionInfo sessioninfo, MA_LIMIT_PRODUCT limitproduct)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_LIMIT_PRODUCTRepository.GetAll().FirstOrDefault(p => p.LIMIT_ID == limitproduct.LIMIT_ID & p.PRODUCT_ID == limitproduct.PRODUCT_ID && p.ID != limitproduct.ID);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                var foundlimitproduct = unitOfWork.MA_LIMIT_PRODUCTRepository.All().FirstOrDefault(p => p.ID == limitproduct.ID);
                if (foundlimitproduct == null)
                {
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                }
                else
                {
                    foundlimitproduct.ID         = limitproduct.ID;
                    foundlimitproduct.LIMIT_ID   = limitproduct.LIMIT_ID;
                    foundlimitproduct.MA_LIMIT   = limitproduct.MA_LIMIT;
                    foundlimitproduct.MA_PRODUCT = limitproduct.MA_PRODUCT;
                    foundlimitproduct.PRODUCT_ID = limitproduct.PRODUCT_ID;

                    unitOfWork.Commit();
                }
            }

            return(limitproduct);
        }
Example #2
0
        public void ValidateProfileFunctionTest()
        {
            LimitProductBusiness_Accessor target = new LimitProductBusiness_Accessor(); // TODO: Initialize to an appropriate value
            MA_LIMIT_PRODUCT data     = null;                                           // TODO: Initialize to an appropriate value
            bool             expected = false;                                          // TODO: Initialize to an appropriate value
            bool             actual;

            actual = target.ValidateProfileFunction(data);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #3
0
        public void CreateLimitProductTest()
        {
            LimitProductBusiness target       = new LimitProductBusiness(); // TODO: Initialize to an appropriate value
            SessionInfo          sessioninfo  = null;                       // TODO: Initialize to an appropriate value
            MA_LIMIT_PRODUCT     limitproduct = null;                       // TODO: Initialize to an appropriate value
            MA_LIMIT_PRODUCT     expected     = null;                       // TODO: Initialize to an appropriate value
            MA_LIMIT_PRODUCT     actual;

            actual = target.CreateLimitProduct(sessioninfo, limitproduct);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #4
0
 public static object Update(SessionInfo sessioninfo, MA_LIMIT_PRODUCT record)
 {
     try
     {
         LimitProductBusiness _limitproductbusiness = new LimitProductBusiness();
         record.LIMIT_ID   = record.LIMIT_ID;
         record.PRODUCT_ID = record.PRODUCT_ID;
         var added = _limitproductbusiness.UpdateLimitProduct(sessioninfo, record);
         return(new { Result = "OK" });
     }
     catch (Exception ex)
     {
         return(new { Result = "ERROR", Message = ex.Message });
     }
 }
Example #5
0
        public MA_LIMIT_PRODUCT CreateLimitProduct(SessionInfo sessioninfo, MA_LIMIT_PRODUCT limitproduct)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (ValidateProfileFunction(limitproduct))
                {
                    unitOfWork.MA_LIMIT_PRODUCTRepository.Add(limitproduct);
                    unitOfWork.Commit();
                }
                else
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }
            }

            return(limitproduct);
        }
Example #6
0
        private bool ValidateProfileFunction(MA_LIMIT_PRODUCT data)
        {
            List <MA_LIMIT_PRODUCT> oldData = null;

            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                oldData = unitOfWork.MA_LIMIT_PRODUCTRepository.GetAll().Where(t => t.PRODUCT_ID == data.PRODUCT_ID && t.LIMIT_ID == data.LIMIT_ID).ToList();
                if (oldData.Count > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Example #7
0
 public static object Update(MA_LIMIT_PRODUCT record)
 {
     return(LimitProductUIP.Update(SessionInfo, record));
 }