コード例 #1
0
        public ActionResult Create([Bind(Include = "Id,Name,EmailID,Password")] user_master user_master)
        {
            if (ModelState.IsValid)
            {
                db.user_master.Add(user_master);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user_master));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "ItemId,CategoryId,ItemCode,ItemName,ShortDescription,LongDescription,SmallImagePath,LongImagePath,ItemPrice")] Item item)
        {
            if (ModelState.IsValid)
            {
                item.ItemId = Guid.NewGuid();
                db.Items.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
コード例 #3
0
 public ActionResult Signup(user_master model)
 {
     using (var context = new ProductManagementEntities())
     {
         context.user_master.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Login"));
 }
コード例 #4
0
        public SupplierVMModel AddAndUpdateSupplier(SupplierVMModel vmModel)
        {
            if (vmModel.ID > 0)
            {
                var record = _db.Suppliers.Where(x => x.ID == vmModel.ID).FirstOrDefault();
                record.Name        = vmModel.Name;
                record.PhoneNumber = vmModel.PhoneNumber;

                _db.SaveChanges();
            }
            else
            {
                Supplier _supplier = new Supplier();
                _supplier.Name        = vmModel.Name;
                _supplier.PhoneNumber = vmModel.PhoneNumber;
                _db.Suppliers.Add(_supplier);
                _db.SaveChanges();
                vmModel.ID = _supplier.ID;
            }
            return(vmModel);
        }
コード例 #5
0
        public ProductSupplierVMModel AddAndUpdateProductSupplier(ProductSupplierVMModel vmModel)
        {
            if (vmModel.ID > 0)
            {
                var record = _db.ProductSuppliers.Where(x => x.ID == vmModel.ID).FirstOrDefault();
                record.ProductID  = vmModel.ProductID;
                record.SupplierID = vmModel.SupplierID;

                _db.SaveChanges();
            }
            else
            {
                ProductSupplier _supplier = new ProductSupplier();
                _supplier.ProductID  = vmModel.ProductID;
                _supplier.SupplierID = vmModel.SupplierID;
                _db.ProductSuppliers.Add(_supplier);
                _db.SaveChanges();
                vmModel.ID = _supplier.ID;
            }
            return(vmModel);
        }
コード例 #6
0
 public ProductVMModel AddAndUpdateProduct(ProductVMModel vmModel)
 {
     if (vmModel.ID > 0)
     {
         var record = _db.Products.Where(x => x.ID == vmModel.ID).FirstOrDefault();
         record.Name     = vmModel.Name;
         record.Price    = vmModel.Price;
         record.Quantity = vmModel.Quantity;
         record.Code     = vmModel.Code;
         _db.SaveChanges();
     }
     else
     {
         Product _product = new Product();
         _product.Name     = vmModel.Name;
         _product.Price    = vmModel.Price;
         _product.Quantity = vmModel.Quantity;
         _product.Code     = vmModel.Code;
         _db.Products.Add(_product);
         _db.SaveChanges();
         vmModel.ID = _product.ID;
     }
     return(vmModel);
 }
コード例 #7
0
        public ActionResult AddProduct(AddProductModel objaddproduct)
        {
            string s_fileName      = Path.GetFileNameWithoutExtension(objaddproduct.SmallImageFile.FileName);
            string s_fileExtension = Path.GetExtension(objaddproduct.SmallImageFile.FileName);

            s_fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + s_fileName.Trim() + s_fileExtension;
            string s_UploadPath = ConfigurationManager.AppSettings["S_UserImagePath"].ToString();

            objaddproduct.SmallImagePath = s_UploadPath + s_fileName;
            objaddproduct.SmallImageFile.SaveAs(objaddproduct.SmallImagePath);

            string l_fileName      = Path.GetFileNameWithoutExtension(objaddproduct.LongImageFile.FileName);
            string l_fileExtension = Path.GetExtension(objaddproduct.LongImageFile.FileName);

            l_fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + l_fileName.Trim() + l_fileExtension;
            string l_UploadPath = ConfigurationManager.AppSettings["L_UserImagePath"].ToString();

            objaddproduct.LongImagePath = l_UploadPath + l_fileName;
            objaddproduct.LongImageFile.SaveAs(objaddproduct.LongImagePath);


            Item obItem = new Item();

            obItem.CategoryId       = Int16.Parse(objaddproduct.Category_Id);
            obItem.ItemCode         = objaddproduct.ItemCode;
            obItem.ItemName         = objaddproduct.ItemName;
            obItem.ShortDescription = objaddproduct.ShortDescription;
            obItem.LongDescription  = objaddproduct.LongDescription;
            obItem.ItemPrice        = objaddproduct.ItemPrice;
            obItem.SmallImagePath   = objaddproduct.SmallImagePath;
            obItem.LongImagePath    = objaddproduct.LongImagePath;
            obItem.ItemId           = Guid.NewGuid();



            dbobj.Items.Add(obItem);
            dbobj.SaveChanges();

            return(View());
        }
コード例 #8
0
 public IHttpActionResult proinsert(ProductDetail proinsert)
 {
     p.ProductDetails.Add(proinsert);
     p.SaveChanges();
     return(Ok());
 }
コード例 #9
0
 private bool Save()
 {
     return(db.SaveChanges() > 0);
 }