public ActionResult Return(LeaseApplyModel model) { try { return(Json(new JsonMessage(business.Return(model)))); } catch (Exception e) { return(Json(new JsonMessage(false, e.Message))); } }
public ActionResult Audit(LeaseApplyModel model) { try { model.AuditUser = CurrentUser.Id; return(Json(new JsonMessage(business.Audit(model)))); } catch (Exception e) { return(Json(new JsonMessage(false, e.Message))); } }
public LeaseApplyModel GetModel(Guid id) { using (DataProvider dp = new DataProvider()) { LeaseApplyModel model = Mapper.Map <LeaseApplyModel>(data.GetLEAModel(dp, id)); if (model != null) { model.AuditDep = dp.PM_Department.Where(m => !m.IsDel && dp.PM_AuditUser.Where(x => x.ApplyId == model.Id).Select(x => x.AuditId).Contains(m.Id)) .Select(m => m.Id).ToList(); model.AuditUserIds = dp.System_User.Where(m => m.IsDel == false && dp.PM_AuditUser.Where(x => x.ApplyId == model.Id).Select(x => x.AuditId).Contains(m.Id)) .Select(m => m.Id).ToList(); } return(model); } }
public bool Return(LeaseApplyModel model) { if (model == null || !model.Id.HasValue) { return(false); } using (DataProvider dp = new DataProvider()) { var entity = data.GetLEAModel(dp, model.Id); entity.ActualReturnTime = model.ActualReturnTime; try { dp.SaveChanges(); return(true); } catch { throw; } } }
public bool Audit(LeaseApplyModel model) { if (model == null || !model.Id.HasValue) { return(false); } using (DataProvider dp = new DataProvider()) { var entity = data.GetLEAModel(dp, model.Id); entity.AuditStatus = model.AuditStatus; entity.AuditReason = model.AuditReason; entity.AuditTime = DateTime.Now; entity.AuditUser = model.AuditUser; try { dp.SaveChanges(); return(true); } catch { throw; } } }
public bool Save(LeaseApplyModel model) { using (DataProvider dp = new DataProvider()) { var entity = data.GetLEAModel(dp, model.Id); if (entity == null) { model.Id = Guid.NewGuid(); model.AuditStatus = AuditStatus.WaitAudit.ToString(); model.IsDel = false; model.CreateTime = DateTime.Now; dp.PM_LeaseApply.Add(Mapper.Map <PM_LeaseApply>(model)); if (model.AuditDep.IsNotNullAndCountGtZero()) { model.AuditDep.ForEach(m => dp.PM_AuditUser.Add(new PM_AuditUser() { ApplyId = model.Id, AuditId = m })); } if (model.AuditUserIds.IsNotNullAndCountGtZero()) { model.AuditUserIds.ForEach(m => dp.PM_AuditUser.Add(new PM_AuditUser() { ApplyId = model.Id, AuditId = m })); } } else { entity.LeaseId = model.LeaseId; entity.LeaseBeginTime = model.LeaseBeginTime; entity.LeaseEndTime = model.LeaseEndTime; entity.ApplyReason = model.ApplyReason; entity.UpdateUser = model.UpdateUser; entity.UpdateTime = DateTime.Now; dp.PM_AuditUser.RemoveRange(dp.PM_AuditUser.Where(m => m.ApplyId == entity.Id)); if (model.AuditDep.IsNotNullAndCountGtZero()) { model.AuditDep.ForEach(m => dp.PM_AuditUser.Add(new PM_AuditUser() { ApplyId = model.Id, AuditId = m })); } if (model.AuditUserIds.IsNotNullAndCountGtZero()) { model.AuditUserIds.ForEach(m => dp.PM_AuditUser.Add(new PM_AuditUser() { ApplyId = model.Id, AuditId = m })); } } try { dp.SaveChanges(); return(true); } catch { throw; } } }