Exemplo n.º 1
0
        public ActionResult UserSignup(SignupModel obj)
        {
            if (ModelState.IsValid)
            {
                RMSEntities rtx  = new RMSEntities();
                var         data = rtx.Customers.FirstOrDefault(i => i.Userid == obj.Userid);
                if (data != null)
                {
                    ModelState.AddModelError("", "Username already exists");
                    return(View("Signup"));
                }
                Customer c = new Customer();
                c.Username  = obj.Username;
                c.Userid    = obj.Userid;
                c.password  = obj.Password;
                c.Usercity  = obj.Usercity;
                c.Uphonenum = long.Parse(obj.Userphno);
                rtx.Customers.Add(c);
                rtx.SaveChanges();

                return(RedirectToAction("UserLogin"));
            }
            else
            {
                return(View("Signup"));
            }
        }
Exemplo n.º 2
0
        public JsonResult AddToCart2(Cart c1)
        {
            RMSEntities ctx = new RMSEntities();

            var data = from a in ctx.Menus.ToList()
                       where a.Rname == Session["Rname"].ToString() &&
                       a.Itemsname == c1.Fooditems
                       select new
            {
                a.Itemsname,
                a.price,
                a.Rname,
            };

            foreach (var item in data)
            {
                Cart c = new Cart();
                c.Fooditems = item.Itemsname;
                c.Price     = item.price;
                c.Rname     = item.Rname;
                c.Quantity  = c1.Quantity;
                ctx.Carts.Add(c);
                ctx.SaveChanges();
                break;
            }
            return(Json(c1, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public JsonResult GetCart2()
        {
            RMSEntities ctx = new RMSEntities();
            //List<UserRest> listRest = new List<UserRest>();
            //foreach (var item in ctx.Restaurants.ToList())
            //{

            //        UserRest u = new UserRest();
            //        u.RName = item.RName;
            //        u.Branch = item.Branch;
            //        u.RType = item.RType;
            //        u.Logo = String.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(item.Logo));
            //        listRest.Add(u);

            //}
            var data = (from a in ctx.Carts.ToList()
                        //where (r1.City==a.City && r1.RName==a.RName)
                        select new
            {
                a.Fooditems,
                a.Price,
                a.Rname,
                a.Quantity
            }).ToList();

            return(Json(data,
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult FinalUpdateMenu(Menu r1, HttpPostedFileBase pfile1)
        {
            RMSEntities ctx = new RMSEntities();

            if (pfile1 != null)
            {
                BinaryReader brd = new BinaryReader(pfile1.InputStream);
                byte[]       bt  = brd.ReadBytes((int)pfile1.InputStream.Length);
                foreach (var item in ctx.Menus)
                {
                    if (r1.Rname == item.Rname && r1.Itemsname == item.Itemsname)
                    {
                        item.Itemimage = bt;
                        item.price     = (int)r1.price;
                        break;
                    }
                }
            }
            else
            {
                foreach (var item in ctx.Menus)
                {
                    if (r1.Rname == item.Rname && r1.Itemsname == item.Itemsname)
                    {
                        item.price = (int)r1.price;
                        break;
                    }
                }
            }
            ctx.SaveChanges();
            return(RedirectToAction("EditMenu"));
        }
Exemplo n.º 5
0
 public JsonResult PlaceOrder2()
 {
     {
         RMSEntities ctx = new RMSEntities();
         foreach (var item in ctx.Carts)
         {
             OrderedFood h1 = new OrderedFood()
             {
                 Userid   = Session["Userid"].ToString(),
                 Rname    = item.Rname,
                 Itemname = item.Fooditems,
                 Price    = item.Price,
                 Quantity = item.Quantity.ToString(),
                 Date     = DateTime.Now
             };
             ctx.OrderedFoods.Add(h1);
         }
         var rows = from a in ctx.Carts
                    select a;
         foreach (var row in rows)
         {
             ctx.Carts.Remove(row);
         }
         ctx.SaveChanges();
         int d = 1;
         return(Json(d, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 6
0
        public ActionResult AddBranch2(Branch r1, HttpPostedFileBase pfile1)
        {
            try
            {
                RMSEntities ctx  = new RMSEntities();
                Branch      obj  = new Branch();
                var         data = ctx.Branches.FirstOrDefault(i => (i.Location == r1.Location && i.bcity == r1.bcity && i.Rname == r1.Rname));

                if (data == null)
                {
                    BinaryReader brd = new BinaryReader(pfile1.InputStream);
                    byte[]       bt  = brd.ReadBytes((int)pfile1.InputStream.Length);
                    r1.bimage = bt;
                    ctx.Branches.Add(r1);

                    ctx.SaveChanges();
                    //ViewBag.Message = "Restaurant Added";
                    TempData["success"] = "Branch Added";
                    return(RedirectToAction("AddBranch"));
                }


                TempData["Error"] = "Duplicate Entry!";
                return(RedirectToAction("AddBranch"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
 private static void CreateLevel(RMSEntities dbContext)
 {
     try
     {
         var levels = new List <string>()
         {
             "100", "200", "300", "400", "500"
         };
         foreach (var level in levels)
         {
             if (!dbContext.Levels.Any(c => c.Name == level))
             {
                 dbContext.Levels.Add(new Level()
                 {
                     Name = level, CreatedAt = DateTime.UtcNow
                 });
                 dbContext.SaveChanges();
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemplo n.º 8
0
        public PurchaseEntryViewModel(PurchaseParams purchaseParams) : base(purchaseParams != null ? purchaseParams.ShowAllCompanies : false)
        {
            if (purchaseParams != null && purchaseParams.ShowAllCompanies)
            {
                Title = "Purchase Entry*";
            }
            else
            {
                Title = "Purchase Entry";
            }

            var count = RMSEntitiesHelper.Instance.RMSEntities.Companies.ToList();

            _purchaseDetailsList = new ObservableCollection <PurchaseDetailExtn>();
            _purchaseDetailsList.CollectionChanged += PurchaseDetailsListCollectionChanged;

            _purchaseParams = purchaseParams;

            RMSEntitiesHelper.Instance.AddPurchaseNotifier(this);
            RMSEntitiesHelper.Instance.SelectRunningBillNo(_categoryId);
            _rmsEntities = new RMSEntities();

            if (purchaseParams != null)
            {
                if (purchaseParams.Billno.HasValue)
                {
                    //Amend Bill
                    OnEditBill(purchaseParams.Billno.Value);
                    Title     = "Purchase Bill Amend : " + _runningBillNo;
                    IsVisible = System.Windows.Visibility.Visible;
                    return;
                }
            }
        }
 private static void CreateSemester(RMSEntities dbContext)
 {
     try
     {
         var roles = new List <string>()
         {
             "Harmattan", "Rain"
         };
         foreach (var role in roles)
         {
             if (!dbContext.Semeters.Any(c => c.Name == role))
             {
                 dbContext.Semeters.Add(new Semeter()
                 {
                     Name = role, CreatedAt = DateTime.UtcNow
                 });
                 dbContext.SaveChanges();
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemplo n.º 10
0
        public JsonResult GetRests2()
        {
            RMSEntities ctx  = new RMSEntities();
            var         data = from a in ctx.Branches.ToList() where a.bcity == Session["Usercity"].ToString()
                               select new { name = a.Rname };
            var data1 = from a in ctx.Restaurants.ToList() join b in data.ToList() on a.Rname equals b.name
                        select new { type = a.Category };
            string s = data1.ToList()[0].type;

            List <UserRest> listRest = new List <UserRest>();

            foreach (var item in ctx.Branches.ToList())
            {
                if (Session["Usercity"].ToString() == item.bcity)
                {
                    UserRest u = new UserRest();
                    u.Rname    = item.Rname;
                    u.Location = item.Location;
                    u.bcity    = item.bcity;
                    u.Category = s;
                    u.bimage   = String.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(item.bimage));
                    listRest.Add(u);
                }
            }
            return(Json(listRest,
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        public ActionResult ValidateUser(Credentials obj)
        {
            if (ModelState.IsValid)
            {
                RMSEntities mtx = new RMSEntities();
                Customer    c1  = mtx.Customers.FirstOrDefault(i => i.Userid == obj.Userid);
                if (c1 == null)
                {
                    TempData["userloginerror"] = "User not found!";
                    return(RedirectToAction("UserLogin"));
                }
                if (obj.Userid == c1.Userid && obj.Password == c1.password)
                {
                    Session["Userid"]   = c1.Userid;
                    Session["Username"] = c1.Username;
                    Session["Usercity"] = obj.Usercity;
                    return(RedirectToAction("Home", "User"));                   /// add user function link here
                }
                else
                {
                    ModelState.AddModelError("", "Invalid User name or password");
                    TempData["userloginerror"] = "Invalid User name or password";
                    return(RedirectToAction("UserLogin"));
                }
            }
            else
            {
                TempData["userloginerror"] = "Enter valid data";

                return(RedirectToAction("UserLogin"));
            }
        }
Exemplo n.º 12
0
        public JsonResult GetAllName()
        {
            RMSEntities stx = new RMSEntities();
            var         d   = from a in stx.Restaurants.ToList()
                              select a.Rname;

            return(Json(d.ToList(), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
        public CustomerViewModel()
        {
            //var names = RMSEntitiesHelper.RMSEntities.Customers.SelectMany(c => c.Name);
            _customer    = new Customer();
            _rmsEntities = new RMSEntities();
            var cnt = _rmsEntities.Categories.Count();

            _customerCategory = _rmsEntities.Categories.Where(c => c.parentId == 1).ToList();
        }
Exemplo n.º 14
0
        public JsonResult GetAllMenu(Menu m1)
        {
            RMSEntities stx = new RMSEntities();
            var         d   = from a in stx.Menus.ToList()
                              where a.Rname == m1.Rname
                              select a.Rname;

            return(Json(d.ToList(), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 15
0
        public JsonResult GetAllCity(Branch b1)
        {
            RMSEntities stx = new RMSEntities();
            var         d   = from a in stx.Branches.ToList() where a.Rname == b1.Rname
                              select a.bcity;

            d = d.Distinct().ToList();
            return(Json(d.ToList(), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 16
0
        public JsonResult Rest5(Restaurant b1)
        {
            RMSEntities stx = new RMSEntities();
            var         d   = from a in stx.Restaurants.ToList()
                              where a.Rname == b1.Rname
                              select a.Category;

            d = d.Distinct().ToList();
            return(Json(d.ToList(), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 17
0
        public ActionResult UserLogin(string Role)
        {
            RMSEntities rtx  = new RMSEntities();
            var         list = from a in rtx.Branches select new { bcity = a.bcity };

            list = list.Distinct();

            ViewBag.list = new SelectList(list.ToList(), "", "bcity");
            return(View());
        }
Exemplo n.º 18
0
        public ProductsViewModel()
        {
            _product     = new Product();
            _rmsEntities = new RMSEntities();
            var cnt = _rmsEntities.Categories.Count();

            _productsCategory  = _rmsEntities.Categories.Where(c => c.parentId == 3).ToList().OrderBy(p => p.name);
            _unitOfMeasureList = _rmsEntities.MeasuringUnits.ToList().OrderBy(p => p.unit);
            _companiesList     = _rmsEntities.Companies.ToList().OrderBy(c => c.Name);
        }
        public static void InitializeIdentityForEf(ApplicationDbContext db)
        {
            var authContext = new ApplicationDbContext();
            var rmsContext  = new RMSEntities();
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(authContext));
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>());

            SetupHelper.SetupRoles(roleManager);
            CrateStartupAdminUsers(userManager);
            CreateLevel(rmsContext);
            CreateSemester(rmsContext);
        }
Exemplo n.º 20
0
        public JsonResult GetTotalPrice2()
        {
            RMSEntities ctx =
                new RMSEntities();
            int data = 0;

            foreach (var item in ctx.Carts.ToList())
            {
                data = data + ((int)item.Price * (int)item.Quantity);
            }
            return(Json(data,
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
        public JsonResult ChangeQuantity2(Cart F)
        {
            RMSEntities ctx = new RMSEntities();

            foreach (var item in ctx.Carts.ToList())
            {
                if (item.Fooditems == F.Fooditems)
                {
                    item.Quantity = F.Quantity;
                    break;
                }
            }
            ctx.SaveChanges();
            return(Json(F, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 22
0
        public JsonResult DelItem2(Menu f1)
        {
            RMSEntities ctx = new RMSEntities();

            foreach (var item in ctx.Menus)
            {
                if (f1.Rname == item.Rname && f1.Itemsname == item.Itemsname)
                {
                    ctx.Menus.Remove(item);
                    break;
                }
            }
            ctx.SaveChanges();
            return(Json(f1));
        }
Exemplo n.º 23
0
        public ActionResult AddMenu2(Menu b1, HttpPostedFileBase pfile1)
        {
            RMSEntities ctx = new RMSEntities();
            string      cat = Request.Form["type2"].ToString();

            try
            {
                foreach (var item in ctx.Restaurants)
                {
                    Menu obj = new Menu();
                    if (cat == "BOTH")
                    {
                        BinaryReader brd = new BinaryReader(pfile1.InputStream);
                        byte[]       bt  = brd.ReadBytes((int)pfile1.InputStream.Length);
                        b1.Itemimage = bt;
                        ctx.Menus.Add(b1);
                        TempData["menu_succ"] = "Menu Added";
                        break;
                    }
                    else
                    {
                        if (item.Rname == b1.Rname && item.Category == b1.Foodtype)
                        {
                            BinaryReader brd = new BinaryReader(pfile1.InputStream);
                            byte[]       bt  = brd.ReadBytes((int)pfile1.InputStream.Length);
                            b1.Itemimage = bt;
                            ctx.Menus.Add(b1);
                            TempData["menu_succ"] = "Menu Added";
                            break;
                        }
                        else
                        {
                            //TempData["dup_msg"] = "Kindly Check Data...";
                            // return RedirectToAction("AddMenu");
                        }
                    }
                }
                ctx.SaveChanges();

                return(RedirectToAction("AddMenu"));
            }
            catch (Exception ex)
            {
                return(View("Error",
                            new HandleErrorInfo(ex, "Admin", "AddBranch")));
                //return View("Error");
            }
        }
Exemplo n.º 24
0
        public JsonResult DeleteItem2(Cart F)
        {
            RMSEntities ctx = new RMSEntities();

            foreach (var item in ctx.Carts.ToList())
            {
                if (item.Fooditems == F.Fooditems)
                {
                    ctx.Carts.Remove(item);
                    break;
                }
            }

            ctx.SaveChanges();
            return(Json(F, JsonRequestBehavior.AllowGet));
        }
        public ReturnSalesViewModel(bool showRestrictedCustomers) : base(showRestrictedCustomers)
        {
            _returnSalesDetailsList = new ObservableCollection <ReturnSaleDetailExtn>();
            _returnSalesDetailsList.CollectionChanged += (s, e) =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    TotalAmount = _returnSalesDetailsList.Sum(r => r.Amount);
                }
            };

            _rmsEntities = RMSEntitiesHelper.Instance.GetNewInstanceOfRMSEntities();
            //_returnPriceList = _rmsEntities.PriceDetails.ToList();
            var cnt = _rmsEntities.Products.ToList();

            //var cnt1= _returnPriceList.Count();
            this.Title = "Return Sales Entry";
        }
Exemplo n.º 26
0
 public ActionResult AddRestaurant2(Restaurant r1, HttpPostedFileBase pfile1)
 {
     try
     {
         RMSEntities  ctx = new RMSEntities();
         BinaryReader brd = new BinaryReader(pfile1.InputStream);
         byte[]       bt  = brd.ReadBytes((int)pfile1.InputStream.Length);
         r1.Rimages = bt;
         ctx.Restaurants.Add(r1);
         ctx.SaveChanges();
         TempData["rest_msg"] = "Restaurant Added";
         return(RedirectToAction("AddRest"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Error", "Home"));
     }
 }
Exemplo n.º 27
0
        public JsonResult GetMenu2()
        {
            RMSEntities   ctx      = new RMSEntities();
            List <Mymenu> listMenu = new List <Mymenu>();

            foreach (var item in ctx.Menus.ToList())
            {
                if (Session["Rname"].ToString() == item.Rname)
                {
                    Mymenu u = new Mymenu();
                    u.Itemsname = item.Itemsname;
                    u.price     = (int)item.price;
                    u.Itemimage = String.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(item.Itemimage));
                    listMenu.Add(u);
                }
            }
            return(Json(listMenu,
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 28
0
        public JsonResult GetHistory2()
        {
            RMSEntities ctx  = new RMSEntities();
            var         data = (from a in ctx.OrderedFoods.ToList()
                                where (a.Userid == Session["Userid"].ToString())
                                select new
            {
                a.Userid,
                a.Rname,
                a.Itemname,
                a.Price,
                a.Quantity,
                Date = a.Date.ToString()
                       //a.DaTi
                       //DaTi = a.DaTi.ToString().Substring(
                       //        0, a.ReleaseDate.ToString().IndexOf(' ')),
                       //DaTi = a.DaTi.ToString()
            }).ToList();

            ctx.SaveChanges();
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 29
0
        public JsonResult Menu5(Menu f1)
        {
            RMSEntities   ctx      = new RMSEntities();
            List <Mymenu> listMenu = new List <Mymenu>();

            foreach (var item in ctx.Menus.ToList())
            {
                if (f1.Rname == item.Rname)
                {
                    Mymenu m = new Mymenu();
                    m.Itemsname = item.Itemsname;
                    m.price     = (int)item.price;
                    m.Itemimage = String.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(item.Itemimage));
                    m.Foodtype  = item.Foodtype;
                    listMenu.Add(m);
                }
            }
            var data1 = from a in ctx.Menus.ToList() where (a.Rname == f1.Rname) select a.Itemsname;

            return(Json(data1.ToList(),
                        JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 30
0
        public JsonResult Branch3(Branch f1)
        {
            RMSEntities     ctx   = new RMSEntities();
            List <Mybranch> listM = new List <Mybranch>();

            foreach (var item in ctx.Branches.ToList())
            {
                if (f1.Rname == item.Rname && f1.bcity == item.bcity && f1.Location == item.Location)
                {
                    Mybranch m = new Mybranch();
                    m.Rname     = item.Rname;
                    m.bcity     = item.bcity;
                    m.Location  = item.Location;
                    m.bimage    = String.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(item.bimage));
                    m.bphonenum = item.bphonenum;
                    listM.Add(m);
                }
            }
            var data1 = from a in ctx.Branches.ToList() where a.Rname == f1.Rname && a.bcity == f1.bcity && a.Location == f1.Location select new { a.bphonenum, a.bimage };

            return(Json(listM, JsonRequestBehavior.AllowGet));
        }