public async Task <ActionResult> DeleteClothesType(int clothesTypeId) { ClothesTypeModel deletedClothesType = await this._typeRepository.DeleteClothesTypeAsync(clothesTypeId); if (deletedClothesType != null) { TempData["message"] = string.Format("Тип одежды \"{0}\" была удалена!", deletedClothesType.Name); } return(RedirectToAction("ListClothesTypes")); }
public async Task <ActionResult> EditClothesType(int?clothesTypeId) { if (clothesTypeId != null) { ClothesTypeModel clothesType = await this._typeRepository.GetClothesTypeByIdAsync((int)clothesTypeId); if (clothesType != null) { return(View(clothesType)); } return(RedirectToAction("ListClothesTypes")); } return(HttpNotFound()); }
public async Task <ActionResult> EditClothesType(ClothesTypeModel clothesType) { if (ModelState.IsValid) { await this._typeRepository.SaveClothesTypeAsync(clothesType); TempData["message"] = string.Format("Изменения в типе одежды \"{0}\" были сохранены", clothesType.Name); return(RedirectToAction("ListClothesTypes")); } else { return(View(clothesType)); } }
public async Task SaveClothesTypeAsync(ClothesTypeModel clothesType) { if (clothesType.ClothesTypeId == 0) { this._context.ClothesTypes.Add(Mapper.Map <ClothesTypeModel, ClothesType>(clothesType)); } else { ClothesType newClothesType = await this._context.ClothesTypes.FindAsync(clothesType.ClothesTypeId); newClothesType.Name = clothesType.Name; } await this._context.SaveChangesAsync(); }
public ActionResult AddClothesType(ClothesTypeModel clothesType) { return(View("EditClothesType", new ClothesTypeModel())); }