private void ConvertToType(UnitTypeViewModel typeVM, MType type) { type.TypeName = typeVM.TypeName; type.TypeStatus = typeVM.TypeStatus; type.TypeDesc = typeVM.TypeDesc; type.MerkId = string.IsNullOrEmpty(typeVM.MerkId) ? null : _merkTasks.One(typeVM.MerkId); }
public ActionResult Create() { var empty = new UnitTypeViewModel(); var data = empty.ToVM(); return(View(data)); }
public JsonResult Create([Bind(Include = "Id, Name")] UnitTypeViewModel unitType) { var response = new JsonResultBody(); string id = string.Empty; try { var mapped = Mapper.Map <UnitTypeViewModel, UnitType>(unitType); id = _repository.Save(mapped); } catch (DbEntityValidationException ex) { response.Status = System.Net.HttpStatusCode.InternalServerError; foreach (DbEntityValidationResult result in ex.EntityValidationErrors) { response.Errors = (from ve in result.ValidationErrors select ve.ErrorMessage).ToList(); } } catch (Exception exAplicacion) { response.Status = System.Net.HttpStatusCode.InternalServerError; response.Errors.Add(exAplicacion.Message); } response.Data = new { Id = id }; return(Json(response)); }
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")); }
public ActionResult Edit([Bind(Include = "Id, Name")] UnitTypeViewModel unitType) { var response = new JsonResultBody(); try { response.Data = _repository.Edit(Mapper.Map <UnitTypeViewModel, UnitType>(unitType)); } catch (DbEntityValidationException ex) { response.Status = System.Net.HttpStatusCode.InternalServerError; foreach (DbEntityValidationResult result in ex.EntityValidationErrors) { response.Errors = (from ve in result.ValidationErrors select ve.ErrorMessage).ToList(); } } catch (Exception exApp) { response.Status = System.Net.HttpStatusCode.InternalServerError; response.Errors.Add(exApp.Message); } return(Json(response)); }
public ActionResult Types_Destroy([DataSourceRequest] DataSourceRequest request, UnitTypeViewModel typeVM) { if (typeVM != null) { var type = _typeTasks.One(typeVM.TypeID); if (type != null) { //type.ModifiedDate = DateTime.Now; //type.ModifiedBy = User.Identity.Name; //type.DataStatus = "Deleted"; _typeTasks.Delete(type); } } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult Types_Update([DataSourceRequest] DataSourceRequest request, UnitTypeViewModel typeVM) { if (typeVM != null && ModelState.IsValid) { var type = _typeTasks.One(typeVM.TypeID); if (type != null) { ConvertToType(typeVM, type); type.ModifiedDate = DateTime.Now; type.ModifiedBy = User.Identity.Name; type.DataStatus = "Updated"; _typeTasks.Update(type); } } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult Types_Create([DataSourceRequest] DataSourceRequest request, UnitTypeViewModel typeVM) { if (typeVM != null && ModelState.IsValid) { MType type = new MType(); type.SetAssignedIdTo(typeVM.TypeID); ConvertToType(typeVM, type); type.CreatedDate = DateTime.Now; type.CreatedBy = User.Identity.Name; type.DataStatus = "New"; _typeTasks.Insert(type); } return(Json(new[] { typeVM }.ToDataSourceResult(request, ModelState))); }
public async Task <ResponseViewModel <UnitTypeViewModel> > DeleteUnitType([FromBody] UnitTypeViewModel unitTypeView) { return(await _adminService.DeleteUnitType(unitTypeView)); }