Exemple #1
0
        public IHttpActionResult Post(Catagory catagory)
        {
            context.Catagories.Add(catagory);
            context.SaveChanges();

            return(Created("api/categories/" + catagory.CatagoriesId, catagory));
        }
Exemple #2
0
        public IHttpActionResult Post(Category category)
        {
            context.Categories.Add(category);
            context.SaveChanges();
            string url = Url.Link("GetById", new { id = category.CategoryId });

            return(Created(url, category));
        }
Exemple #3
0
 public IActionResult Create([Bind("Name", "Description", "Quantity", "Unit", "SupplierName")] Item item, IFormFile image)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     if (image != null)
     {
         var filename = Path.Combine(_environment.WebRootPath, Path.GetFileName(image.FileName));
         image.CopyTo(new FileStream(filename, FileMode.Create));
         item.Image = image.FileName;
     }
     _context.Items.Add(item);
     _context.SaveChanges();
     return(View());
 }
 public IActionResult Create([Bind("Name", "Description", "Quantity", "Unit", "SupplierName")] Chemical chemical)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     chemical.CreatedAt = DateTime.Now;
     chemical.UpdatedAt = DateTime.Now;
     _context.Chemicals.Add(chemical);
     _context.SaveChanges();
     return(View());
 }
 public void Insert(T entity)
 {
     context.Set <T>().Add(entity);
     context.SaveChanges();
 }