public ActionResult GetMayorizationDetailEntries(MayorizationDetailViewModel vm) { var param = db.Params.Find(1); var entries = db.CountableEntries .Where(e => e.AccountId == vm.AccountId && e.AsientoDate.Year == param.ProcessYear && e.AsientoDate.Month == param.ProcessMoth) .ToList(); var vmList = Mapper.Map(entries, new List<CountableEntryViewModel>()); return Json(new { Result = "OK", Data = vmList }); }
public ActionResult Save(MayorizationDetailViewModel vm) { if (ModelState.ContainsKey("FechaRegistro")) { ModelState["FechaRegistro"].Errors.Clear(); } var mayorizationDetail = Mapper.Map(vm, new MayorizationDetail()); if (ModelState.IsValid) { string mensaje = ""; if (mayorizationDetail.Id > 0) { db.MayorizationDetails.Attach(mayorizationDetail); db.Entry(mayorizationDetail).State = EntityState.Modified; db.SaveChanges(); mensaje = "Datos Actualizados."; } else { db.MayorizationDetails.Add(mayorizationDetail); db.SaveChanges(); mensaje = "Registro Creado"; } vm.Id = mayorizationDetail.Id; return Json(new { Result = "OK", Data = vm, Message = mensaje }); } return Json(new { Result = "ERROR", Message = "Hay Datos erroneos" }); }