Whenever I save my data of Products the Id of products starts with 1006 etc but not with 1. And Also My table doesn't save anything in the status column
Here is the Picture of my Table
The ProductID starts with 1006
This is my Controller Code for adding Products
[HttpPost]
public ActionResult ProductsView(product model)
{
product tbl = new product();
string fileName = Path.GetFileNameWithoutExtension(model.ImageFile.FileName);
string extension = Path.GetExtension(model.ImageFile.FileName);
fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
tbl.ProductName = model.ProductName;
tbl.ProductDescription = model.ProductDescription;
tbl.Price = model.Price;
tbl.Quantity = model.Quantity;
tbl.CategoryName = model.CategoryName;
tbl.Status = model.Status;
tbl.Image = "~/Image/" + fileName;
fileName = Path.Combine(Server.MapPath("~/Image/"), fileName);
model.ImageFile.SaveAs(fileName);
db.products.Add(tbl);
db.SaveChanges();
return View();
}
This is my Product Model
public partial class product
{
public int ProductID { get; set; }
public string ProductName { get; set; }
public string ProductDescription { get; set; }
public Nullable<decimal> Price { get; set; }
public Nullable<int> Quantity { get; set; }
public string CategoryName { get; set; }
public Nullable<int> CategoryID { get; set; }
[DisplayName("Upload Image")]
public string Image { get; set; }
public HttpPostedFileBase ImageFile { get; set; }
public string Status { get; set; }
public virtual category category { get; set; }
}
and This is my View
@model myadminpanel.Models.product
@using (Html.BeginForm("ProductsView","Product",FormMethod.Post,new { enctype="multipart/form-data"}))
{
<div class="container">
<div class="form-group">
<label>Item Name</label>
<input class="form-control" name="ProductName" placeholder="Enter Product Name" />
</div>
<div class="form-group">
<label>Item Description</label>
<input class="form-control" name="ProductDescription" placeholder="Enter Item Description" />
</div>
<div class="form-group">
<label>Item Price</label>
<input class="form-control" name="Price" placeholder="Enter Item Price" />
</div>
<div class="form-group">
<label>Item Quantity</label>
<input class="form-control" name="Quantity" placeholder="Enter Item Quantity" />
</div>
<div class="form-group">
<label>Category Name</label>
<input class="form-control" name="CategoryName" placeholder="Select Category Name" />
</div>
<div class="form-group">
<label>Satus(Available/Not Available)</label>
<input class="form-control" name="Satus" placeholder="Enter Satus As Available/Not Available" />
</div>
<div class="form-group">
<label>Item Image</label>
<input type="file" name="ImageFile" required />
</div>
<div class="button">
<button>Submit</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Show/Edit/Delete", "ProductShow", "Product")</li>
</ul>
</div>
</div>
}