Exemplo n.º 1
0
        public static int AddMenu(Menu ad)
        {
            int ins = 0;
            try
            {
                int? maxPos = GetMaxPosition();
                if (ad.Position != null)
                {
                    if (maxPos == null)
                    {
                        ad.Position = 1;
                    }
                    else
                    {
                        if (ad.Position > maxPos)
                        {
                            ad.Position = maxPos + 1;
                        }
                        else {
                            UpdatePostion((int)ad.Position,null,"asc");
                        }
                    }
                }
                ins = DataAccessLayer.MenuDA.AddMenu(ad);
            }
            catch (Exception)
            {
                return 0;
            }

            return ins;
        }
Exemplo n.º 2
0
        public ActionResult CreateChineseBuffet(Menu m)
        {
            m.MenuTypeId = 1;

            BLLServiceGateway<Menu> gate = new BLLServiceGateway<Menu>();

            gate.PostItems("api/Menu/", m);

            return RedirectToAction("AdminChineseBuffet");
        }
Exemplo n.º 3
0
        public IHttpActionResult PostMenu(Menu menu)
        {
            DALServiceGateway<Menu> gate = new DALServiceGateway<Menu>();

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            gate.PostItems("api/Menu/", menu);
            return CreatedAtRoute("DefaultApi", new { id = menu.Id }, menu);
        }
Exemplo n.º 4
0
        public IHttpActionResult PutMenu(int id, Menu menu)
        {
            DALServiceGateway<Menu> gate = new DALServiceGateway<Menu>();

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != menu.Id)
            {
                return BadRequest();
            }

            if (id != menu.Id)
            {
                return BadRequest();
            }

            gate.PutItems("api/Menu/" + id, menu);

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 5
0
        public ActionResult CreateProcess(FormCollection frm)
        {
            int kt = 0;
            try
            {

                int? postion = null;
                if (frm["Position"] != null && frm["Position"] != "")
                {
                    postion = int.Parse(frm["Position"]);
                }
                // TODO: Add insert logic here
                Models.Menu ad = new Models.Menu()
                {
                    Subject = frm["Subject"],
                    TextTooltip = frm["TextTooltip"],
                    Links = frm["Links"],
                    Position = postion
                };

                kt = MenuBusiness.AddMenu(ad);
            }
            catch
            {
                kt = 0;
            }

            if (kt > 0)
            {
                return RedirectToAction("ListMenu", "Menus", new { add = "success" });
            }
            else
            {
                return RedirectToAction("ListMenu", "Menus", new { add = "error" });
            }
        }
Exemplo n.º 6
0
        public ActionResult CreateSushiTake(Menu m)
        {
            m.MenuTypeId = 2;

            BLLServiceGateway<Menu> gate = new BLLServiceGateway<Menu>();

            gate.PostItems("api/Menu/", m);

            return RedirectToAction("AdminSushiTake");
        }
Exemplo n.º 7
0
        public static int EditMenu(Menu ad)
        {
            int upt = 0;
            int check = 0;
            try
            {
                Menu mOld=MenuBusiness.GetMenuById(ad.Id)[0];
                int? maxPos = GetMaxPosition();

                if (ad.Position != null && mOld.Position!=ad.Position)
                {
                    if (maxPos == null)
                    {
                        ad.Position = 1;
                    }
                    else
                    {
                        if (mOld.Position != null)
                        {
                            if (ad.Position >= maxPos)
                            {
                                UpdatePostionDesc((int)mOld.Position);
                                ad.Position = maxPos;
                            }
                            else
                            {
                                if (ad.Position < mOld.Position)
                                {
                                    UpdatePostion((int)ad.Position,null,"asc");
                                    check = 1;
                                }
                                else
                                {
                                    UpdatePostion((int)ad.Position, mOld.Position, "desc");
                                }
                            }
                        }
                        else
                        {
                            if (ad.Position > maxPos)
                            {
                                ad.Position = maxPos + 1;
                            }
                            else
                            {
                                int kt = UpdatePostion((int)ad.Position,null,"asc");
                            }
                        }
                    }
                }
                else if (ad.Position == null && mOld.Position!= null)
                {
                    UpdatePostionDesc((int)mOld.Position);
                }
                upt = DataAccessLayer.MenuDA.EditMenu(ad);
                if (upt > 0 && check == 1)
                {
                    UpdatePostionDesc((int)mOld.Position);
                }
            }
            catch (Exception)
            {
                return 0;
            }
            return upt;
        }
Exemplo n.º 8
0
        private static List<Menu> AddMenuToList(DataTable dt)
        {
            List<Menu> ls = new List<Menu>();
            try
            {

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int? position = null;
                    if (dt.Rows[i]["Position"].ToString() != null && dt.Rows[i]["Position"].ToString() != "")
                    {
                        position = int.Parse(dt.Rows[i]["Position"].ToString());
                    }
                    Menu ad = new Menu()
                    {
                        Id = int.Parse(dt.Rows[i]["Id"].ToString()),
                        Subject = dt.Rows[i]["Subject"].ToString(),
                        TextTooltip = dt.Rows[i]["TextTooltip"].ToString(),
                        Position = position,
                        IsDeleted = int.Parse(dt.Rows[i]["IsDeleted"].ToString()),
                        Links = dt.Rows[i]["Links"].ToString()

                    };

                    ls.Add(ad);

                }
            }
            catch (Exception)
            {
                return new List<Menu>();
            }
            return ls;
        }