public async Task <IActionResult> Edit(int id, [Bind("ProductTypeId,Name,Description,ImagePath,IsActive,CreatedAt,CreatedBy,UpdatedAt,UpdatedBy")] Producttype producttype) { if (id != producttype.ProductTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(producttype); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProducttypeExists(producttype.ProductTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(producttype)); }
public async Task <Producttype> DeleteProducttypeAsync(int producttypeID) { Producttype dbEntry = context.Producttypes.Find(producttypeID); if (dbEntry != null) { context.Producttypes.Remove(dbEntry); await context.SaveChangesAsync(); } return(dbEntry); }
public async Task <IActionResult> Create([Bind("ProductTypeId,Name,Description,ImagePath,IsActive,CreatedAt,CreatedBy,UpdatedAt,UpdatedBy")] Producttype producttype) { if (ModelState.IsValid) { _context.Add(producttype); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(producttype)); }
/// <summary> /// Add a new Producttype to Context and check if the passed object is valid. /// </summary> /// <param name="producttype"></param> /// <returns></returns> public async Task <IHttpActionResult> PostProducttype(Producttype producttype) { if (ModelState.IsValid) { await this.repository.SaveProducttypeAsync(producttype); return(Ok()); } else { return(BadRequest(ModelState)); } }
public async Task <int> SaveProducttypeAsync(Producttype producttype) { if (producttype.ProducttypeID == 0) { context.Producttypes.Add(producttype); } else { Producttype dbEntry = context.Producttypes.Find(producttype.ProducttypeID); if (dbEntry != null) { dbEntry.Name = producttype.Name; dbEntry.Description = producttype.Description; } } return(await context.SaveChangesAsync()); }
public bool Equals([AllowNull] Product other) { if (other != null) { if (ReferenceEquals(this, other)) { return(true); } if (ReferenceEquals(this, null)) { return(false); } if (ReferenceEquals(other, null)) { return(false); } if (GetType() != other.GetType()) { return(false); } if (Id == other.Id && Bodyhtml == other.Bodyhtml && CreatedAt == other.CreatedAt && Handle.IsEquals(other.Handle) && Producttype.IsEquals(other.Producttype) && PublishedScope.IsEquals(other.PublishedScope) && Tags.IsEquals(other.Tags) && Title.IsEquals(other.Title) && Image.Equals(other.Image) ) { return(true); } } return(false); }