public IActionResult Save(KeyResultAreaIndexViewModel model) { var UserId = HttpContext.Session.GetString("UserId"); if (ModelState.IsValid) { var item = new KeyResultArea { Id = model.Id, Title = model.Title, Description = model.Description, Weight = 100 }; if (model.Id == 0) { item.CreatedBy = UserId; item.CreationDate = DateTime.Now; _Services.Add(item); } else { item.ModifiedBy = UserId; item.ModifiedDate = DateTime.Now; _Services.Update(item); } return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", model)); } }
public async Task <IActionResult> UpdateKPI(int empId, string KeyResultAreaId, JsonPatchDocument <KeyResultAreaForUpdateDto> entityForUpdate) { ObjectId Id = new ObjectId(KeyResultAreaId); var keyResult = await resultArea.QuerySingleByUserId(Id, empId); if (keyResult == null) { return(NotFound()); } var aa = new KeyResultAreaForUpdateDto(); var resultAreaToPatch = mapper.Map <KeyResultArea, KeyResultAreaForUpdateDto>(keyResult); entityForUpdate.ApplyTo(resultAreaToPatch); mapper.Map(resultAreaToPatch, keyResult); var entityToUpdate = await resultArea.Update(Id, keyResult); var entityToReturn = mapper.Map <KeyResultAreaDtoForCreation>(entityToUpdate); return(Ok(entityToReturn)); }