Exemple #1
0
        public ActionResult Create(FormCollection collection)
        {
            bool   DidItWork  = false;
            string CrudAction = "Create";

            try
            {
                BusinessLayerLibrary.Attribute a = new BusinessLayerLibrary.Attribute();

                #region Pull from Form Collection
                a.AttributeDesc       = (string)collection["AttributeDesc"];
                a.Seasonal            = Convert.ToInt32(collection["ddSeasonal"]);
                a.AttributeOrder      = Convert.ToInt32(collection["AttributeOrder"]);
                a.SapName             = (string)collection["SapName"];
                a.PlmName             = (string)collection["PlmName"];
                a.DataTypeID          = Convert.ToInt32(collection["ddDataType"]);
                a.FutureSeasonCascade = Convert.ToInt32(collection["ddCascade"]);
                a.Calculated          = Convert.ToInt32(collection["ddCalculated"]);
                #endregion

                StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name);
                if (DidItWork == false)
                {
                    return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name)));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemple #2
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            bool   DidItWork  = false;
            string CrudAction = "Delete";

            try
            {
                AttributeBusinessLayer         bl = new AttributeBusinessLayer();
                BusinessLayerLibrary.Attribute a  = bl.Attributes.Where(i => i.AttributeID == id).Single();

                StoredProcedureBusinessLayer spbl = new StoredProcedureBusinessLayer();
                DidItWork = spbl.ExecuteStoredProcedure(a, CrudAction, User.Identity.Name);
                if (DidItWork == false)
                {
                    return(Content(string.Format("Error on {0} of {1}. Press back to return and try again", CrudAction, a.GetType().Name)));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }