public IActionResult Post([FromBody] UnitTypeModel unitType) { try { _unitTypeService.Add(unitType.ToDomainModel()); } catch (System.Exception ex) { ModelState.AddModelError("AddUnitType", ex.GetBaseException().Message); return(BadRequest(ModelState)); } return(CreatedAtAction("Get", new { Id = unitType.Id }, unitType)); }
public IHttpActionResult AddUnitType(UnitType s_UnitType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _UnitTypeService.Add(s_UnitType); return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(UnitTypeViewModel unitType) { if (!ModelState.IsValid) { ErrorNotification("Kayıt Eklenemedi!"); return(RedirectToAction("Create")); } _unitTypeService.Add(new UnitType { UnitTypeName = unitType.UnitTypeName }); SuccessNotification("Kayıt Eklendi."); return(RedirectToAction("UnitTypeIndex")); }
public ActionResult Create(UnitTypeViewModel unitType) { if (!ModelState.IsValid) { ErrorNotification("Kayıt Eklenemedi!"); return(RedirectToAction("Create")); } _unitTypeService.Add(new UnitType { //TODO:Alanlar buraya yazılacak //Örn:BrandName = brand.BrandName, }); SuccessNotification("Kayıt Eklendi."); return(RedirectToAction("UnitTypeIndex")); }