Ejemplo n.º 1
0
 public HttpResponseMessage getSite()
 {
     try
     {
         using (PRINCE_STGEntities enBI = new PRINCE_STGEntities())
         {
             enBI.Configuration.LazyLoadingEnabled = false;
             List <Site> siteList = enBI.Site.Where(a => a.Status == "A").OrderBy(od => od.Description).ToList();
             return(Request.CreateResponse(HttpStatusCode.OK, siteList));
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 2
0
 public TransList getSite(int pg, int tk, string fnd)
 {
     try
     {
         int       skip      = tk * (pg - 1); // skip the record
         TransList transList = new TransList();
         using (PRINCE_STGEntities db = new PRINCE_STGEntities())
         {
             db.Configuration.LazyLoadingEnabled = false;
             if (string.IsNullOrEmpty(fnd))
             {
                 List <Site> site = db.Site.AsNoTracking()
                                    .OrderBy(od => od.Description)
                                    .Skip(skip)
                                    .Take(tk)
                                    .ToList();
                 transList.totalCount = db.Site.AsNoTracking().Count();
                 transList.data       = site;
             }
             else
             {
                 List <Site> site = db.Site.AsNoTracking()
                                    .Where(wr => wr.Description.Contains(fnd) || wr.Status.Contains(fnd))
                                    .OrderBy(od => od.Description)
                                    .Skip(skip)
                                    .Take(tk)
                                    .ToList();
                 transList.totalCount = db.Site.AsNoTracking().Where(wr => wr.Description.Contains(fnd) || wr.Status.Contains(fnd)).Count();
                 transList.data       = site;
             }
         }
         return(transList);
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 3
0
 public HttpResponseMessage updatePlan(dynamic pPlan)
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             using (var dbCtxTran = enBi.Database.BeginTransaction())
             {
                 //DateTime plandate = pPlan.PLAN_DATE;
                 int id = pPlan.ID;
                 //string storecode = pPlan.STORE_CODE;
                 STG_PLAN plan = enBi.STG_PLAN.Find(id);
                 if (plan != null)
                 {
                     plan.ID                        = pPlan.ID;
                     plan.PLAN_DATE                 = pPlan.PLAN_DATE;
                     plan.GEO_LEVEL1_CODE           = pPlan.GEO_LEVEL1_CODE;
                     plan.GEO_LEVEL2_CODE           = pPlan.GEO_LEVEL2_CODE;
                     plan.GEO_LEVEL3_CODE           = pPlan.GEO_LEVEL3_CODE;
                     plan.STORE_CODE                = pPlan.STORE_CODE;
                     plan.PROD_LEVEL1_CODE          = pPlan.PROD_LEVEL1_CODE;
                     plan.PROD_LEVEL2_CODE          = pPlan.PROD_LEVEL2_CODE;
                     plan.PROD_LEVEL3_CODE          = pPlan.PROD_LEVEL3_CODE;
                     plan.PROD_LEVEL4_CODE          = pPlan.PROD_LEVEL4_CODE;
                     plan.PROD_LEVEL5_CODE          = pPlan.PROD_LEVEL5_CODE;
                     plan.PRODUCT_CODE              = pPlan.PRODUCT_CODE;
                     plan.PLAN_VERSION              = pPlan.PLAN_VERSION;
                     plan.PLAN_SALE_QTY             = pPlan.PLAN_SALE_QTY;
                     plan.PLAN_SALE_VAL_AT_PRICE    = pPlan.PLAN_SALE_VAL_AT_PRICE;
                     plan.PLAN_SALE_VAL_AT_COST     = pPlan.PLAN_SALE_VAL_AT_COST;
                     plan.PLAN_MARKDOWN_QTY         = pPlan.PLAN_MARKDOWN_QTY;
                     plan.PLAN_MARKDOWN_VAL         = pPlan.PLAN_MARKDOWN_VAL;
                     plan.PLAN_SHRINKAGE_VAL        = pPlan.PLAN_SHRINKAGE_VAL;
                     plan.PLAN_PURCHASE_QTY         = pPlan.PLAN_PURCHASE_QTY;
                     plan.PLAN_PURCHASE_VAL         = pPlan.PLAN_PURCHASE_VAL;
                     plan.PLAN_INV_OPENING_QTY      = pPlan.PLAN_INV_OPENING_QTY;
                     plan.PLAN_OPENING_VAL_AT_COST  = pPlan.PLAN_OPENING_VAL_AT_COST;
                     plan.PLAN_OPENING_VAL_AT_PRICE = pPlan.PLAN_OPENING_VAL_AT_PRICE;
                     plan.PLAN_OTH1                 = pPlan.PLAN_OTH1;
                     plan.PLAN_OTH2                 = pPlan.PLAN_OTH2;
                     plan.PLAN_OTH3                 = pPlan.PLAN_OTH3;
                     plan.PLAN_OTH4                 = pPlan.PLAN_OTH4;
                     plan.PLAN_OTH5                 = pPlan.PLAN_OTH5;
                     plan.ARC_DATE                  = pPlan.ARC_DATE;
                     enBi.Entry(plan).State         = System.Data.Entity.EntityState.Modified;
                     enBi.SaveChanges();
                     dbCtxTran.Commit();
                     return(Request.CreateResponse(HttpStatusCode.OK, "Plan successfully Updated."));
                 }
             }
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     return(Request.CreateResponse(HttpStatusCode.OK, "Plan successfully Updated."));
 }
Ejemplo n.º 4
0
 public HttpResponseMessage getSiteById(int id)
 {
     try
     {
         using (PRINCE_STGEntities enCarina = new PRINCE_STGEntities())
         {
             enCarina.Configuration.LazyLoadingEnabled = false;
             Site site = enCarina.Site.Where(wr => wr.SiteId == id).SingleOrDefault();
             return(Request.CreateResponse(HttpStatusCode.OK, site));
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 5
0
 public ActionResult SaveData(List <STG_DIM_STOCKAGE_BAND> stockage)
 {
     try
     {
         bool status = false;
         if (ModelState.IsValid)
         {
             using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
             {
                 foreach (var i in stockage)
                 {
                     enBi.STG_DIM_STOCKAGE_BAND.Add(i);
                 }
                 enBi.SaveChanges();
                 status = true;
             }
         }
         return(new JsonResult {
             Data = new { status = status }
         });
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 6
0
 public List <Menu> getMenu(int id)
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             int    iId    = id;
             int?[] arMenu = (from a in enBi.UserMenu.AsNoTracking() where a.UserId == iId && a.Status == "A" select a.MenuId).ToArray();
             var    menu   = (from a in enBi.Menu.AsNoTracking() where a.Status == "A" && arMenu.Contains(a.Id) select a).OrderBy(c => c.LevelNo).ThenBy(d => d.SortNo).ToList();
             return(menu);
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 7
0
 public HttpResponseMessage getUserMenuList(int pUserCode)
 {
     try
     {
         using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
         {
             // List<UserMenu> menu = (from m in entPrince.UserMenu where m.UserId == pUserCode select m).ToList();
             var menuList = from um in entPrince.UserMenu join m in entPrince.Menu on um.MenuId equals m.Id where um.UserId == pUserCode
                            select new {
                 m.Code,
                 m.Name,
                 m.ParentId,
                 m.LevelNo,
                 m.SortNo,
                 um.CanAdd,
                 um.CanDelete,
                 um.CanEdit,
                 um.CanView,
                 um.UserId
             };
             List <TempUserMenu> tempUserMenu = new List <TempUserMenu>();
             foreach (var m in menuList)
             {
                 TempUserMenu tu = new TempUserMenu();
                 tu.Code      = m.Code;
                 tu.Name      = m.Name;
                 tu.ParentId  = m.ParentId;
                 tu.LevelNo   = m.LevelNo;
                 tu.SortNo    = m.SortNo;
                 tu.canAdd    = m.CanAdd;
                 tu.canDelete = m.CanDelete;
                 tu.canEdit   = m.CanEdit;
                 tu.canView   = m.CanView;
                 tu.UserId    = m.UserId;
                 tempUserMenu.Add(tu);
             }
             return(Request.CreateResponse(HttpStatusCode.OK, tempUserMenu));
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 8
0
 public HttpResponseMessage updateStore(StoreDc pStore)
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             using (var dbCtxTran = enBi.Database.BeginTransaction())
             {
                 TEMP_STORE store = enBi.TEMP_STORE.Where(wr => wr.STORE_CODE == pStore.STORE_CODE).FirstOrDefault();
                 if (store != null)
                 {
                     store.STORE_DESCRIPTION     = pStore.STORE_DESCRIPTION;
                     store.AREA_MANAGER          = pStore.AREA_MANAGER;
                     store.AREA_MANAGER_DESC     = pStore.AREA_MANAGER_DESC;
                     store.REGIONAL_MANAGER      = pStore.REGIONAL_MANAGER;
                     store.REGIONAL_MANAGER_DESC = pStore.REGIONAL_MANAGER_DESC;
                     store.SOM                = pStore.SOM;
                     store.SOM_DESC           = pStore.SOM_DESC;
                     store.SENIOR_SOM         = pStore.SENIOR_SOM;
                     store.SENIOR_SOM_DESC    = pStore.SENIOR_SOM_DESC;
                     store.STORE_OPENING_HOUR = pStore.STORE_OPENING_HOUR;
                     store.STORE_CLOSING_HOUR = pStore.STORE_CLOSING_HOUR;
                     store.STORE_LATITUDE     = pStore.STORE_LATITUDE;
                     store.STORE_LONGITUDE    = pStore.STORE_LONGITUDE;
                     enBi.Entry(store).State  = EntityState.Modified;
                     enBi.SaveChanges();
                     dbCtxTran.Commit();
                 }
             }
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     return(Request.CreateResponse(HttpStatusCode.OK));
 }
Ejemplo n.º 9
0
 public List <User> getUser()
 {
     try {
         using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
         {
             List <User> user = (from u in entPrince.User select u).ToList();
             return(user);
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 10
0
 public UserMenu getUserMenu(int pUserCode, int pMenuId)
 {
     try {
         using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
         {
             UserMenu menu = (from m in entPrince.UserMenu where m.UserId == pUserCode && m.MenuId == pMenuId select m).SingleOrDefault();
             return(menu);
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 11
0
 public HttpResponseMessage login(User pUser)
 {
     try {
         String emailAdd = pUser.EmailAdd;
         String password = pUser.Password;
         using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
         {
             User user = (from u in entPrince.User where u.EmailAdd == emailAdd && u.Status == "A" select u).SingleOrDefault();
             if (user.Password == password)
             {
                 TempUser tempUser = new TempUser();
                 tempUser.Id        = user.Id;
                 tempUser.Code      = user.Code;
                 tempUser.EmailAdd  = user.EmailAdd;
                 tempUser.FirstName = user.FirstName;
                 tempUser.LastName  = user.LastName;
                 tempUser.Status    = user.Status;
                 return(Request.CreateResponse(HttpStatusCode.Accepted, tempUser));
             }
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 12
0
 public HttpResponseMessage updateTarget(dynamic pTarget)
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             using (var dbCtxTran = enBi.Database.BeginTransaction())
             {
                 //DateTime merchdate = sStoreMerch.merch_DATE;
                 int id = pTarget.ID;
                 //string storecode = sStoreMerch.STORE_CODE;
                 STG_TARGET target = enBi.STG_TARGET.Find(id);
                 if (target != null)
                 {
                     target.ID                       = pTarget.ID;
                     target.TARGET_DATE              = pTarget.TARGET_DATE;
                     target.GEO_LEVEL1_CODE          = pTarget.GEO_LEVEL1_CODE;
                     target.GEO_LEVEL2_CODE          = pTarget.GEO_LEVEL2_CODE;
                     target.GEO_LEVEL3_CODE          = pTarget.GEO_LEVEL3_CODE;
                     target.STORE_CODE               = pTarget.STORE_CODE;
                     target.PROD_LEVEL1_CODE         = pTarget.PROD_LEVEL1_CODE;
                     target.PROD_LEVEL2_CODE         = pTarget.PROD_LEVEL2_CODE;
                     target.PROD_LEVEL3_CODE         = pTarget.PROD_LEVEL3_CODE;
                     target.PROD_LEVEL4_CODE         = pTarget.PROD_LEVEL4_CODE;
                     target.PROD_LEVEL5_CODE         = pTarget.PROD_LEVEL5_CODE;
                     target.PRODUCT_CODE             = pTarget.PRODUCT_CODE;
                     target.TARGET_SALE_QTY          = pTarget.TARGET_SALE_QTY;
                     target.TARGET_SALE_VAL_AT_PRICE = pTarget.TARGET_SALE_VAL_AT_PRICE;
                     target.TARGET_SALE_VAL_AT_COST  = pTarget.TARGET_SALE_VAL_AT_COST;
                     target.ARC_DATE                 = pTarget.ARC_DATE;
                     enBi.Entry(target).State        = System.Data.Entity.EntityState.Modified;
                     enBi.SaveChanges();
                     dbCtxTran.Commit();
                     return(Request.CreateResponse(HttpStatusCode.OK, "Target successfully Updated."));
                 }
             }
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     return(Request.CreateResponse(HttpStatusCode.OK, "Target successfully Updated."));
 }
Ejemplo n.º 13
0
 public dynamic getAllMenu()
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             int?[] arMenu = (from a in enBi.UserMenu.AsNoTracking() where a.Status == "A"  select a.MenuId).ToArray();
             var    menu   = (from a in enBi.Menu.AsNoTracking()
                              where a.Status == "A" && arMenu.Contains(a.Id) && a.ParentId != 0
                              select new {
                 a.Code,
                 a.Name,
                 canAdd = false,
                 canEdit = false,
                 canDelete = false,
                 canView = false,
                 a.LevelNo,
                 a.SortNo
             }
                              ).OrderBy(c => c.LevelNo).ThenBy(d => d.SortNo).ToList();
             return(menu);
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 14
0
 public HttpResponseMessage addSite(dynamic pSite)
 {
     try
     {
         using (PRINCE_STGEntities dbCtx = new PRINCE_STGEntities())
         {
             int    tempSite     = pSite.SiteId;
             String tempSiteDesc = pSite.Description;
             Site   site         = dbCtx.Site.AsNoTracking().Where(wr => wr.SiteId == tempSite).SingleOrDefault();
             if (site != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.Conflict, "Site Id: " + tempSite.ToString() + " already exist."));
             }
             Site objSite = new Site();
             objSite.SiteId      = tempSite;
             objSite.Description = tempSiteDesc.Trim();
             objSite.Status      = "A";
             dbCtx.Site.Add(objSite);
             dbCtx.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.Created, "Site " + objSite.Description.Trim() + " is successfully created."));
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 15
0
        public HttpResponseMessage saveUserMenu(List <TempUserMenu> pUser)
        {
            try
            {
                if (pUser.Count > 0)
                {
                    int?userId = pUser[0].UserId;
                    using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
                    {
                        List <UserMenu> listUserMenu = (from um in entPrince.UserMenu where um.UserId == userId select um).ToList();
                        foreach (UserMenu uMenu in listUserMenu)
                        {
                            foreach (TempUserMenu tUmenu in pUser)
                            {
                                if (uMenu.Code == tUmenu.Code)
                                {
                                    uMenu.CanAdd    = tUmenu.canAdd;
                                    uMenu.CanEdit   = tUmenu.canEdit;
                                    uMenu.CanDelete = tUmenu.canDelete;
                                    uMenu.CanView   = tUmenu.canView;
                                    break;
                                }
                            }
                            entPrince.Entry(uMenu).State = EntityState.Modified;
                        }

                        entPrince.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.OK, "User Access Successfully Updated!"));
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.NotModified));
            }
            catch (DbEntityValidationException ex)
            {
                ExceptionEntity exDesc = new ExceptionEntity(ex);
                throw new ApiException()
                      {
                          HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
                      };
            }
            catch (Exception ex)
            {
                ExceptionDescription exDesc = new ExceptionDescription(ex);
                throw new ApiException()
                      {
                          HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
                      };
            }
        }
Ejemplo n.º 16
0
 public HttpResponseMessage updateSite(dynamic pSite)
 {
     try
     {
         using (var dbCtx = new PRINCE_STGEntities())
         {
             int    tempSite     = pSite.SiteId;
             String tempSiteDesc = pSite.Description;
             Site   site         = dbCtx.Site.AsNoTracking().Where(wr => wr.SiteId == tempSite).SingleOrDefault();
             site.Description        = tempSiteDesc;
             site.Status             = pSite.Status;
             dbCtx.Entry(site).State = System.Data.Entity.EntityState.Modified;
             dbCtx.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.OK, "Site " + site.Description.Trim() + " is successfully Updated."));
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 17
0
        public TransList getUser(int pg, int tk, string fnd)
        {
            try
            {
                int       skip      = tk * (pg - 1); // skip the record
                TransList transList = new TransList();

                using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
                {
                    var user = (from u in entPrince.User select new { u.Id, u.Code, u.EmailAdd, u.FirstName, u.LastName, u.Status })
                               .OrderBy(od => od.LastName)
                               .Skip(skip)
                               .Take(tk)
                               .ToList();

                    transList.totalCount = entPrince.User.AsNoTracking().Count();
                    transList.data       = user;

                    return(transList);
                }
            }
            catch (Exception ex)
            {
                ExceptionDescription exDesc = new ExceptionDescription(ex);
                throw new ApiException()
                      {
                          HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
                      };
            }
        }
Ejemplo n.º 18
0
 public List <TEMP_DC> getStoreDc()
 {
     try
     {
         TransList trans = new TransList();
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             List <TEMP_DC> listDc = enBi.TEMP_DC.AsNoTracking().ToList();
             //  trans.data = listDc;
             return(listDc);
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
 }
Ejemplo n.º 19
0
        public TransList getUserActive()
        {
            try
            {
                TransList transList = new TransList();

                using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities())
                {
                    var user = (from u in entPrince.User where u.Status == "A"
                                select new {
                        u.Id,
                        u.Code,
                        u.EmailAdd,
                        u.FirstName,
                        u.LastName,
                        u.Status
                    })
                               .OrderBy(od => od.LastName)
                               .ToList();

                    transList.totalCount = entPrince.User.AsNoTracking().Count();
                    transList.data       = user;

                    return(transList);
                }
            }
            catch (Exception ex)
            {
                ExceptionDescription exDesc = new ExceptionDescription(ex);
                throw new ApiException()
                      {
                          HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
                      };
            }
        }
Ejemplo n.º 20
0
 public HttpResponseMessage updateStockAge(dynamic sStockAge)
 {
     try
     {
         using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
         {
             using (var dbCtxTran = enBi.Database.BeginTransaction())
             {
                 //DateTime merchdate = sStoreMerch.merch_DATE;
                 int    id      = sStockAge.ID;
                 string bndDesc = sStockAge.PRICE_BAND_CODE;
                 string lvlCode = sStockAge.PROD_LEVEL1_CODE;
                 //string storecode = sStoreMerch.STORE_CODE;
                 STG_DIM_STOCKAGE_BAND stockage = enBi.STG_DIM_STOCKAGE_BAND.Find(id, bndDesc, lvlCode);
                 if (stockage != null)
                 {
                     stockage.ID = sStockAge.ID;
                     stockage.STOCKAGE_BAND_DESC      = sStockAge.PRICE_BAND_DESC;
                     stockage.STKAGE_PROD_LEVEL1_CODE = sStockAge.PROD_LEVEL1_CODE;
                     stockage.STOCKAGE_BAND_LOWER     = sStockAge.PRICE_BAND_LOWER;
                     stockage.STOCKAGE_BAND_UPPER     = sStockAge.PRICE_BAND_UPPER;
                     stockage.STOCKAGE_BAND_SEQ       = sStockAge.STOCKAGE_BAND_SEQ;
                     stockage.LATEST            = sStockAge.LATEST;
                     stockage.ARC_DATE          = sStockAge.ARC_DATE;
                     enBi.Entry(stockage).State = System.Data.Entity.EntityState.Modified;
                     enBi.SaveChanges();
                     dbCtxTran.Commit();
                     return(Request.CreateResponse(HttpStatusCode.OK, "Price Band successfully Updated."));
                 }
             }
         }
     }
     catch (DbEntityValidationException ex)
     {
         ExceptionEntity exDesc = new ExceptionEntity(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     catch (Exception ex)
     {
         ExceptionDescription exDesc = new ExceptionDescription(ex);
         throw new ApiException()
               {
                   HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
               };
     }
     return(Request.CreateResponse(HttpStatusCode.OK, "Price Band successfully Updated."));
 }
Ejemplo n.º 21
0
        //public HttpResponseMessage addStoreMerch(dynamic sStoreMerch)
        //{
        //    try
        //    {
        //        using (PRINCE_STGEntities dbCtx = new PRINCE_STGEntities())
        //        {
        //            STG_merch merch = new STG_merch();
        //                merch.merch_DATE = sStoreMerch.merch_DATE;
        //                merch.GEO_LEVEL1_CODE = "99999";
        //                merch.GEO_LEVEL2_CODE = "99999";
        //                merch.GEO_LEVEL3_CODE = "99999";
        //                merch.STORE_CODE = sStoreMerch.STORE_CODE;
        //                merch.PROD_LEVEL1_CODE = sStoreMerch.PROD_LEVEL1_CODE;
        //                merch.PROD_LEVEL2_CODE = sStoreMerch.PROD_LEVEL2_CODE;
        //                merch.PROD_LEVEL3_CODE = sStoreMerch.PROD_LEVEL3_CODE;
        //                merch.PROD_LEVEL4_CODE = "99999";
        //                merch.PROD_LEVEL5_CODE = "99999";
        //                merch.PRODUCT_CODE = "99999";
        //                merch.merch_VERSION = 99999;
        //                merch.merch_SALE_QTY = 99999;
        //                merch.merch_SALE_VAL_AT_PRICE = sStoreMerch.merch_SALE_VAL_AT_PRICE;
        //                merch.merch_SALE_VAL_AT_COST = 99999;
        //                merch.merch_MARKDOWN_QTY = 0;
        //                merch.merch_MARKDOWN_VAL = 0;
        //                merch.merch_SHRINKAGE_VAL = 0;
        //                merch.merch_PURCHASE_QTY = 0;
        //                merch.merch_PURCHASE_VAL = 0;
        //                merch.merch_INV_OPENING_QTY = 0;
        //                merch.merch_OPENING_VAL_AT_COST = 0;
        //                merch.merch_OPENING_VAL_AT_PRICE = 0;
        //                merch.merch_OTH1 = 99999;
        //                merch.merch_OTH2 = 99999;
        //                merch.merch_OTH3 = 99999;
        //                merch.merch_OTH4 = 99999;
        //                merch.merch_OTH5 = 99999;
        //                merch.ARC_DATE = DateTime.Now;

        //            dbCtx.STG_merch.Add(merch);
        //            dbCtx.SaveChanges();
        //            return Request.CreateResponse(HttpStatusCode.Created, "merch successfully created.");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
        //    }
        //    return Request.CreateResponse(HttpStatusCode.OK);
        //}


        public HttpResponseMessage updateStoreMerch(dynamic sStoreMerch)
        {
            try
            {
                using (PRINCE_STGEntities enBi = new PRINCE_STGEntities())
                {
                    using (var dbCtxTran = enBi.Database.BeginTransaction())
                    {
                        //DateTime merchdate = sStoreMerch.merch_DATE;
                        int id = sStoreMerch.ID;
                        //string storecode = sStoreMerch.STORE_CODE;
                        STG_STR_MERCH_DET merch = enBi.STG_STR_MERCH_DET.Find(id);
                        if (merch != null)
                        {
                            merch.ID                = sStoreMerch.ID;
                            merch.STRMRGRP_DATE     = sStoreMerch.STRMRGRP_DATE;
                            merch.STORE_CODE        = sStoreMerch.STORE_CODE;
                            merch.PROD_LEVEL1_CODE  = sStoreMerch.PROD_LEVEL1_CODE;
                            merch.PROD_LEVEL2_CODE  = sStoreMerch.PROD_LEVEL2_CODE;
                            merch.PROD_LEVEL3_CODE  = sStoreMerch.PROD_LEVEL3_CODE;
                            merch.PROD_LEVEL4_CODE  = sStoreMerch.PROD_LEVEL4_CODE;
                            merch.SELLING_AREA      = sStoreMerch.SELLING_AREA;
                            merch.TOTAL_AREA        = sStoreMerch.TOTAL_AREA;
                            merch.PERMENANT_FTE     = sStoreMerch.PERMENANT_FTE;
                            merch.CONTRACT_FTE      = sStoreMerch.CONTRACT_FTE;
                            merch.OTH_DET1          = sStoreMerch.OTH_DET1;
                            merch.OTH_DET2          = sStoreMerch.OTH_DET2;
                            merch.OTH_DET3          = sStoreMerch.OTH_DET3;
                            merch.OTH_DET4          = sStoreMerch.OTH_DET4;
                            merch.OTH_DET5          = sStoreMerch.OTH_DET5;
                            merch.ARC_DATE          = sStoreMerch.ARC_DATE;
                            enBi.Entry(merch).State = System.Data.Entity.EntityState.Modified;
                            enBi.SaveChanges();
                            dbCtxTran.Commit();
                            return(Request.CreateResponse(HttpStatusCode.OK, "Store Merch successfully Updated."));
                        }
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                ExceptionEntity exDesc = new ExceptionEntity(ex);
                throw new ApiException()
                      {
                          HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
                      };
            }
            catch (Exception ex)
            {
                ExceptionDescription exDesc = new ExceptionDescription(ex);
                throw new ApiException()
                      {
                          HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException()
                      };
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "Storemerch successfully Updated."));
        }