示例#1
0
        public ActionResult Create([Bind(Include = "Brand_Name,Model_Name,Launch,Camera,Ram,Battery,Network,weight,Memory")] phone phone)
        {
            if (ModelState.IsValid)
            {
                db.phones.Add(phone);
                db.SaveChanges();
                TempData["SuccessMessage"] = "New Record Added Successfuly!";
                return(RedirectToAction("Index"));
            }

            return(View(phone));
        }
示例#2
0
 public bool EditItem(ItemDTO pItemDTO)
 {
     using (db = new MobileEntities())
     {
         ITEM item = db.ITEMs.SingleOrDefault(n => n.Id == pItemDTO.Id);
         if (item == null)
         {
             return(false);
         }
         try
         {
             item.Id       = pItemDTO.Id;
             item.Name     = pItemDTO.Name;
             item.Ram      = pItemDTO.Ram;
             item.Pin      = pItemDTO.Pin;
             item.Camera   = pItemDTO.Camera;
             item.Cpu      = pItemDTO.Cpu;
             item.Price    = pItemDTO.Price;
             item.Image    = pItemDTO.Image;
             item.Quantity = pItemDTO.Quantity;
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
示例#3
0
 public bool AddItem(ItemDTO pItemDTO)
 {
     using (db = new MobileEntities())
     {
         ITEM item = DALUtilitiesMethod.ToItem(pItemDTO);
         try
         {
             db.ITEMs.Add(item);
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
 public bool AddSubCategory(SubCategoryDTO pSubCategoryDTO)
 {
     using (db = new MobileEntities())
     {
         SUBCATEGORY subCategory = DALUtilitiesMethod.ToSubCategory(pSubCategoryDTO);
         try
         {
             db.SUBCATEGORies.Add(subCategory);
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
 public bool DeleteSubCategory(int pSubCategoryID)
 {
     using (db = new MobileEntities())
     {
         SUBCATEGORY subCategory = db.SUBCATEGORies.SingleOrDefault(n => n.Id == pSubCategoryID);
         try
         {
             db.SUBCATEGORies.Remove(subCategory);
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
示例#6
0
 public bool AddCategory(CategoryDTO pCategoryDTO)
 {
     using (db = new MobileEntities())
     {
         CATEGORY category = DALUtilitiesMethod.ToCategory(pCategoryDTO);
         try
         {
             db.CATEGORies.Add(category);
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
示例#7
0
        public bool DeleteItem(int pItemID)
        {
            using (db = new MobileEntities())
            {
                ITEM item = db.ITEMs.SingleOrDefault(n => n.Id == pItemID);

                try
                {
                    item.CATEGORies.Clear();
                    item.SUBCATEGORies.Clear();
                    db.ITEMs.Remove(item);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
示例#8
0
 public bool EditCategory(CategoryDTO pCategoryDTO)
 {
     using (db = new MobileEntities())
     {
         CATEGORY category = db.CATEGORies.SingleOrDefault(n => n.Id == pCategoryDTO.Id);
         if (category == null)
         {
             return(false);
         }
         try
         {
             category.Name = pCategoryDTO.Name;
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
 public bool EditSubCategory(SubCategoryDTO pSubCategoryDTO)
 {
     using (db = new MobileEntities())
     {
         SUBCATEGORY subCategory = db.SUBCATEGORies.SingleOrDefault(n => n.Id == pSubCategoryDTO.Id);
         if (subCategory == null)
         {
             return(false);
         }
         try
         {
             subCategory.CategoryId = pSubCategoryDTO.CategoryId;
             subCategory.Name       = pSubCategoryDTO.Name;
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
示例#10
0
 public ActionResult EditMobile(tblMobile mobiledata)
 {
     mobileEntities.Entry(mobiledata).State = EntityState.Modified;
     mobileEntities.SaveChanges();
     return(RedirectToAction("ShowMobiles"));
 }