public ActionResult Create(MovementViewModel model) { try { if (ModelState.IsValid) { try { Service.Movement mov = new Services.Nomina.Movement(); mov.CopyPropertiesFrom(model); var idEmp = model.EmpleadoSelect.Split('-'); mov.Empleado = new Services.Nomina.Employee(); mov.Empleado.Id = Convert.ToInt32(idEmp[0].Trim()); var serviceNomina = GetService.nominaService; serviceNomina.AddUpdateMovimientos(mov); return(Json(new { isError = false, isWarning = false, isSuccess = true, msj = "¡Los datos fueron guardados correctamente!", newurl = "" })); } catch (Exception ex) { return(Json(new { isError = true, isWarning = false, isSuccess = false, msj = ex.Message })); } } else { return(Json(new { isError = false, isWarning = true, isSuccess = false, msj = Errors.getModelError(ModelState) })); } //return RedirectToAction("Index"); } catch { return(View()); } }
public ActionResult Edit(MovementViewModel model) { try { if (ModelState.IsValid) { try { Service.Movement mov = new Services.Nomina.Movement(); mov.CopyPropertiesFrom(model); var idEmp = model.EmpleadoSelect.Split('-'); mov.Empleado = new Services.Nomina.Employee(); mov.Empleado.Id = Convert.ToInt32(idEmp[0].Trim()); var serviceNomina = GetService.nominaService; serviceNomina.AddUpdateMovimientos(mov); return(Json(new { isError = false, isWarning = false, isSuccess = true, msj = "¡Los datos fueron Actualizados correctamente!", newurl = Url.Action("Index", "Movement", new { fechaInicio = DateTime.Now.AddDays(-DateTime.Now.Day + 1).Date, fechaFin = DateTime.Now.AddDays(-DateTime.Now.Day).AddMonths(1), idEmpleado = 0 }) })); } catch (Exception ex) { return(Json(new { isError = true, isWarning = false, isSuccess = false, msj = ex.Message })); } } else { return(Json(new { isError = false, isWarning = true, isSuccess = false, msj = Errors.getModelError(ModelState) })); } //return RedirectToAction("Index"); } catch { return(View()); } }