Example #1
0
        public void CategoriesList_UpdateData(int CategoryId)
        {
            FrontierAg.Models.Category item = null;
            item = _db.Categories.Find(CategoryId);

            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", CategoryId));
                return;
            }

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                _db.SaveChanges();
            }
        }
Example #2
0
        // This is the Insert method to insert the entered Contact item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new FrontierAg.Models.Contact();
                item.DateCreated = DateTime.Now;
                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.Contacts.Add(item);

                    if (item.Type == CType.Customer)
                    {
                        var item2 = new FrontierAg.Models.Shipping();
                        item2.Company     = item.Company;
                        item2.FName       = item.FName;
                        item2.LName       = item.LName;
                        item2.Other1      = "";
                        item2.Other2      = "";
                        item2.Address1    = item.Address1;
                        item2.Address2    = item.Address2;
                        item2.City        = item.City;
                        item2.State       = item.State;
                        item2.PostalCode  = item.PostalCode;
                        item2.Country     = item.Country;
                        item2.PPhone      = item.PPhone;
                        item2.SType       = SType.Shipping;
                        item2.DateCreated = item.DateCreated;
                        item2.ContactId   = item.ContactId;
                        _db.Shippings.Add(item2);

                        var item3 = new FrontierAg.Models.Shipping();
                        item3.Company     = item.Company;
                        item3.FName       = item.FName;
                        item3.LName       = item.LName;
                        item3.Other1      = "";
                        item3.Other2      = "";
                        item3.Address1    = item.Address1;
                        item3.Address2    = item.Address2;
                        item3.City        = item.City;
                        item3.State       = item.State;
                        item3.PostalCode  = item.PostalCode;
                        item3.Country     = item.Country;
                        item3.PPhone      = item.PPhone;
                        item3.SType       = SType.Billing;
                        item3.DateCreated = item.DateCreated;
                        item3.ContactId   = item.ContactId;
                        _db.Shippings.Add(item3);
                    }

                    _db.SaveChanges();
                    Response.Redirect("~/Admin/Contacts/Default");
                }
            }
        }
Example #3
0
        // This is the Delete methd to delete the selected Contact item
        // USAGE: <asp:FormView DeleteMethod="DeleteItem">
        public void DeleteItem(int ContactId)
        {
            using (_db)
            {
                var item = _db.Contacts.Find(ContactId);

                if (item != null)
                {
                    _db.Contacts.Remove(item);
                    _db.SaveChanges();
                }
            }
            Response.Redirect("../Default");
        }
Example #4
0
        public void addPriceForm_InsertItem()
        {
            var item = new FrontierAg.Models.Price();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here
                using (FrontierAg.Models.ProductContext db = new FrontierAg.Models.ProductContext())
                {
                    db.Prices.Add(item);
                    db.SaveChanges();
                }
            }
        }
Example #5
0
        public void addProductForm_InsertItem()
        {
            var item = new FrontierAg.Models.Product();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here
                using (FrontierAg.Models.ProductContext db = new FrontierAg.Models.ProductContext())
                {
                    item.DateCreated = DateTime.Now;
                    db.Products.Add(item);
                    db.SaveChanges();
                }
            }
        }
Example #6
0
 // The id parameter name should match the DataKeyNames value set on the control
 public void PricesGrid_UpdateItem(int PriceId)
 {
     FrontierAg.Models.Price item = null;
     item = _db.Prices.Find(PriceId);
     // Load the item here, e.g. item = MyDataLayer.Find(id);
     if (item == null)
     {
         // The item wasn't found
         ModelState.AddModelError("", String.Format("Item with id {0} was not found", PriceId));
         return;
     }
     TryUpdateModel(item);
     if (ModelState.IsValid)
     {
         // Save changes here, e.g. MyDataLayer.SaveChanges();
         _db.SaveChanges();
     }
 }
Example #7
0
        // This is the Update methd to update the selected Contact item
        // USAGE: <asp:FormView UpdateMethod="UpdateItem">
        public void UpdateItem(int ContactId)
        {
            using (_db)
            {
                var item = _db.Contacts.Find(ContactId);

                if (item == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("", String.Format("Item with id {0} was not found", ContactId));
                    return;
                }

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes here
                    _db.SaveChanges();
                    Response.Redirect("~/Admin/Contacts/Default");
                }
            }
        }