Exemple #1
0
 protected virtual ActionResult CreatePost(Product oNewProduct, HttpPostedFileBase Imagename, FormCollection pFormCollection)
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int compId = cp.CompanyID;
             int userID = cp.CurrentUserId;
             if (Imagename != null && Imagename.ContentLength > 0)
             {
                 oNewProduct.Image = new FileUploader().uploadFile(Imagename, oNewProduct.ProductName, ConstantEnums.FileUploaderPath.Product);
             }
             oNewProduct.CreatedOn = DateTime.Now;
             oNewProduct.IsActive  = true;
             oNewProduct.IsDeleted = false;
             oNewProduct.CompanyID = compId;
             oNewProduct.CreatedBy = userID;
             ProductRepo.addProduct(oNewProduct);
             this.ShowMessage(ConstantEnums.MessageType.Success, "Product Details Saved Successfully!");
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("CreatePost", "Product"));
     }
 }
Exemple #2
0
 protected virtual ActionResult Edit(int id)
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int      compId    = cp.CompanyID;
             int      userID    = cp.CurrentUserId;
             Category oCategory = CatRepo.getCategory(id, compId).FirstOrDefault();
             if (oCategory != null)
             {
                 return(View(oCategory));
             }
             else
             {
                 return(HandleException.CustomException("Edit", "Category"));
             }
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Edit", "Category"));
     }
 }
Exemple #3
0
 protected virtual ActionResult CreatePost(Category oNewCategory, FormCollection oNewForm)
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int compId = cp.CompanyID;
             int userID = cp.CurrentUserId;
             oNewCategory.CreatedOn = DateTime.Now;
             oNewCategory.IsActive  = true;
             oNewCategory.IsDeleted = false;
             oNewCategory.CompanyID = compId;
             oNewCategory.CreatedBy = userID;
             CatRepo.addCategory(oNewCategory);
             this.ShowMessage(ConstantEnums.MessageType.Success, "Category Details Saved Successfully!");
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("CreatePost", "Category"));
     }
 }
Exemple #4
0
 protected virtual ActionResult Delete(int id)
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int      compId    = cp.CompanyID;
             int      userID    = cp.CurrentUserId;
             Category oCategory = CatRepo.getCategory(id, compId).FirstOrDefault();
             if (oCategory != null)
             {
                 oCategory.IsActive  = false;
                 oCategory.IsDeleted = true;
                 oCategory.DeletedOn = DateTime.Now;
                 oCategory.DeletedBy = userID;
                 CatRepo.updateCategory(oCategory);
                 this.ShowMessage(ConstantEnums.MessageType.Success, "Category Deleted Successfully");
             }
             else
             {
                 return(HandleException.CustomException("Delete", "Category"));
             }
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Delete", "Category"));
     }
 }
 protected virtual ActionResult Index()
 {
     try
     {
         if (UserAuthorization.IsLoggedIn())
         {
             return(RedirectToAction("Index", "DashBoard", new { area = "Admin" }));
         }
         return(View("Index"));
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Index", "Login"));
     }
 }
Exemple #6
0
 protected virtual ActionResult Create()
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int compId = cp.CompanyID;
             return(View());
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Create", "Category"));
     }
 }
Exemple #7
0
        public ActionResult Index(SystemUser oSystemUser, FormCollection oNewForm)
        {
            try
            {
                if (oSystemUser.LoginID == null || oSystemUser.Password == null || oSystemUser.Password == string.Empty || oSystemUser.LoginID == string.Empty)
                {
                    TempData["LoginError"] = "Invalid LoginId or password";
                    return(View("Index"));
                }
                var oUser = SystemUserRepo.getSystemUser(oSystemUser.LoginID, oSystemUser.Password).FirstOrDefault();
                if (oUser != null)
                {
                    CustomPrincipalSerializeModel serializeModel = new CustomPrincipalSerializeModel();
                    serializeModel.CurrentUserId   = oUser.UserId;
                    serializeModel.LoginId         = oUser.LoginID;
                    serializeModel.CurrentUserName = oUser.Name;
                    serializeModel.CompanyID       = oUser.CompanyID.Value;
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    string userData = serializer.Serialize(serializeModel);
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket
                                                               (1, oUser.UserId.ToString(), DateTime.Now, DateTime.Now.AddHours(8), false, userData);

                    string     encTicket = FormsAuthentication.Encrypt(authTicket);
                    HttpCookie faCookie  = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                    faCookie.Expires = DateTime.Now.AddHours(8);
                    Response.Cookies.Add(faCookie);
                    System.Web.HttpContext.Current.Response.Cookies.Add(faCookie);
                    System.Web.HttpContext.Current.Request.Cookies.Add(faCookie);
                    return(RedirectToAction("Index", "DashBoard", new { area = "Admin" }));
                }
                else
                {
                    TempData["LoginError"] = "Invalid LoginId or password";
                }
                return(View("Index"));
            }
            catch (Exception ex)
            {
                return(HandleException.CustomException("IndexPost", "Login"));
            }
        }
Exemple #8
0
 protected virtual ActionResult Index()
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int companyid = cp.CompanyID;
             int userID    = cp.CurrentUserId;
             return(View("Index"));
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Index", "Dashboard"));
     }
 }
Exemple #9
0
 protected virtual ActionResult Create()
 {
     try
     {
         CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
         if (cp != null)
         {
             int compId = cp.CompanyID;
             int userID = cp.CurrentUserId;
             ViewBag.SequenceNo   = ProductRepo.getProduct(compId).Select(o => o.SequenceNo).Max() + 1;
             ViewBag.CategoryList = CatRepo.getCategory(compId);
             return(View());
         }
         else
         {
             return(RedirectToAction("Index", "Login"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Create", "Product"));
     }
 }
Exemple #10
0
 protected virtual ActionResult Edit(int id)
 {
     try
     {
         if (id > 0)
         {
             CustomPrincipal cp = (System.Web.HttpContext.Current.User as CustomPrincipal);
             if (cp != null)
             {
                 int compId = cp.CompanyID;
                 ViewBag.CategoryList = CatRepo.getCategory(compId);
                 Product oProduct = ProductRepo.getProduct(id, compId).FirstOrDefault();
                 if (oProduct != null)
                 {
                     return(View(oProduct));
                 }
                 else
                 {
                     return(HandleException.CustomException("Edit", "Product"));
                 }
             }
             else
             {
                 return(RedirectToAction("Index", "Login"));
             }
         }
         else
         {
             return(HandleException.CustomException("Edit", "Product"));
         }
     }
     catch (Exception ex)
     {
         return(HandleException.CustomException("Edit", "Product"));
     }
 }