コード例 #1
0
        public void Delete(string value)
        {
            var dataQuery = new MenuCategoryDataModel();

            dataQuery.MenuCategoryId = int.Parse(value);
            MenuCategoryDataManager.Delete(dataQuery, SessionVariables.RequestProfile);
        }
コード例 #2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var notDeletableIds = new List <int>();
                var deleteIndexList = DeleteIds.Split(',');

                foreach (var index in deleteIndexList)
                {
                    var data = new MenuCategoryDataModel();
                    data.MenuCategoryId = int.Parse(index);

                    if (!MenuCategoryDataManager.IsDeletable(data, SessionVariables.RequestProfile))
                    {
                        notDeletableIds.Add((int)(data.MenuCategoryId));
                    }
                }

                if (notDeletableIds.Count == 0)
                {
                    foreach (var index in deleteIndexList)
                    {
                        var data = new MenuCategoryDataModel();
                        data.MenuCategoryId = int.Parse(index);

                        MenuCategoryDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }
                else
                {
                    var msg = String.Empty;

                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "MenuCategoryId: " + id + " has detail records";
                    }

                    foreach (string index in deleteIndexList)
                    {
                        var data = new MenuCategoryDataModel();
                        data.MenuCategoryId = int.Parse(index);

                        MenuCategoryDataManager.DeleteChildren(data, SessionVariables.RequestProfile);
                        MenuCategoryDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }