public ActionResult Delete(int id) { var message = "OK"; DataSource <PositionViewModel> Source = new DataSource <PositionViewModel>(); PeopleTraining PeopleTrain = _hrUnitOfWork.TrainingRepository.GetpeopleTraining(id); if (PeopleTrain != null) { AutoMapper(new Models.AutoMapperParm { Source = PeopleTrain, ObjectName = "PeopleTrains ", Transtype = TransType.Delete }); _hrUnitOfWork.TrainingRepository.Remove(PeopleTrain); } Source.Errors = SaveChanges(Language); if (Source.Errors.Count() > 0) { return(Json(Source)); } else { return(Json(message)); } }
public IHttpActionResult SavePeopleTrain(PeopleTrainFormViewModel model) { List <Model.ViewModel.Error> errors = new List <Model.ViewModel.Error>(); if (!ModelState.IsValid) { return(Json(Utils.ParseFormError(ModelState))); } string message = "Ok"; if (model.EmpId == 0) { model.EmpId = User.Identity.GetEmpId(); } model.EmpId = 1042; var record = _hrUnitOfWork.Repository <PeopleTraining>().FirstOrDefault(a => a.Id == model.Id); //insert if (record == null) { record = new PeopleTraining(); AutoMapperParm parms = new AutoMapperParm() { Source = model, Destination = record }; AutoMapper(parms); record.CreatedUser = User.Identity.Name; record.CreatedTime = DateTime.Now; record.CompanyId = User.Identity.GetDefaultCompany(); record.ApprovalStatus = 6; record.RequestDate = DateTime.Now; _hrUnitOfWork.TrainingRepository.Add(record); } //update else { AutoMapperParm parms = new AutoMapperParm() { Source = model, Destination = record }; AutoMapper(parms); record.ModifiedTime = DateTime.Now; record.ModifiedUser = User.Identity.Name; record.CompanyId = User.Identity.GetDefaultCompany(); record.RequestDate = DateTime.Now; record.ApprovalStatus = 6; _hrUnitOfWork.TrainingRepository.Attach(record); _hrUnitOfWork.TrainingRepository.Entry(record).State = EntityState.Modified; } var Errors = SaveChanges(User.Identity.GetLanguage()); if (Errors.Count > 0) { message = Errors.First().errors.First().message; } return(Ok(message)); }
public void Remove(PeopleTraining person) { if (Context.Entry(person).State == EntityState.Detached) { context.PeopleTraining.Attach(person); } context.PeopleTraining.Remove(person); }
public ActionResult SendTo(int Id, byte?Send, int?ManagerId) { PeopleTraining PTrainObj = _hrUnitOfWork.TrainingRepository.GetPeopleTraining(Id); string error = ""; if (Send == 1) { _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "PeopleTrainFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = MsgUtils.Instance.Trls("EmployeeReview"), ValueBefore = MsgUtils.Instance.Trls("Submit") }); PTrainObj.ApprovalStatus = 3; error = AddWFTrans(PTrainObj, null, true); } else if (Send == 2) { _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "PeopleTrainFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = MsgUtils.Instance.Trls("ManagerReview"), ValueBefore = MsgUtils.Instance.Trls("Submit") }); PTrainObj.ApprovalStatus = 4; error = AddWFTrans(PTrainObj, ManagerId, null); } if (error.Length > 0) { return(Json(error)); } _hrUnitOfWork.TrainingRepository.Attach(PTrainObj); _hrUnitOfWork.TrainingRepository.Entry(PTrainObj).State = EntityState.Modified; var Errors = SaveChanges(Language); if (Errors.Count > 0) { var message = Errors.First().errors.First().message; return(Json(message)); } return(Json("Ok")); }
public IHttpActionResult Delete(int id) { string message = "Ok"; DataSource <TrainIndexFollowUpViewModel> Source = new DataSource <TrainIndexFollowUpViewModel>(); PeopleTraining PeopleTrain = _hrUnitOfWork.TrainingRepository.GetpeopleTraining(id); _hrUnitOfWork.TrainingRepository.Remove(PeopleTrain); Source.Errors = SaveChanges(User.Identity.GetLanguage()); if (Source.Errors.Count() > 0) { return(Json(Source)); } else { return(Ok(message)); } }
private string AddWFTrans(PeopleTraining PTrainObj, int?ManagerId, bool?backToEmp) { WfViewModel wf = new WfViewModel() { Source = "Training", SourceId = CompanyId, DocumentId = PTrainObj.Id, RequesterEmpId = PTrainObj.EmpId, ApprovalStatus = PTrainObj.ApprovalStatus, CreatedUser = UserName, }; if (ManagerId != null) { wf.ManagerId = ManagerId; } else if (backToEmp != null) { wf.BackToEmployee = backToEmp.Value; } var wfTrans = _hrUnitOfWork.LeaveRepository.AddWorkFlow(wf, Language); PTrainObj.WFlowId = wf.WFlowId; if (wfTrans == null && wf.WorkFlowStatus != "Success") { return(wf.WorkFlowStatus); } else if (wfTrans == null && wf.WorkFlowStatus == "Success") { PTrainObj.ApprovalStatus = 6; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } return(""); }
public DbEntityEntry <PeopleTraining> Entry(PeopleTraining person) { return(Context.Entry(person)); }
public void Attach(PeopleTraining person) { context.PeopleTraining.Attach(person); }
public void Add(PeopleTraining person) { context.PeopleTraining.Add(person); }
public ActionResult Details(TrainEventFormViewModel model, OptionsViewModel moreInfo) { List <Error> errors = new List <Error>(); if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.SiteRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "TrainEvents", TableName = "TrainEvents", ParentColumn = "CourseId", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } TrainEvent record; PeopleTraining PeopleTrainObj = new PeopleTraining(); var message = "OK"; //insert if (model.Id == 0) { record = new TrainEvent(); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "TrainEvents", Options = moreInfo, Transtype = TransType.Insert }); record.CreatedUser = UserName; record.CreatedTime = DateTime.Now; _hrUnitOfWork.TrainingRepository.Add(record); } //booking else if (model.book) { record = _hrUnitOfWork.Repository <TrainEvent>().FirstOrDefault(a => a.Id == model.Id); PeopleTrainObj.CreatedUser = UserName; PeopleTrainObj.CreatedTime = DateTime.Now; PeopleTrainObj.CompanyId = CompanyId; PeopleTrainObj.ApprovalStatus = 2; PeopleTrainObj.RequestDate = DateTime.Now; PeopleTrainObj.EmpId = (model.PersonId != null ? model.PersonId.Value: User.Identity.GetEmpId()); PeopleTrainObj.CourseEDate = model.TrainEndDate; PeopleTrainObj.CourseSDate = model.TrainStartDate; PeopleTrainObj.EventId = record.Id; PeopleTrainObj.CompanyId = CompanyId; PeopleTrainObj.Cost = record.Cost; PeopleTrainObj.Curr = record.Curr; PeopleTrainObj.CurrRate = record.CurrRate; PeopleTrainObj.Notes = record.Notes; PeopleTrainObj.CourseId = record.CourseId; PeopleTrainObj.Adwarding = record.Adwarding; _hrUnitOfWork.TrainingRepository.Add(PeopleTrainObj); } //update else { record = _hrUnitOfWork.Repository <TrainEvent>().FirstOrDefault(a => a.Id == model.Id); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "TrainEvents", Options = moreInfo, Transtype = TransType.Update }); record.ModifiedTime = DateTime.Now; record.ModifiedUser = UserName; _hrUnitOfWork.TrainingRepository.Attach(record); _hrUnitOfWork.TrainingRepository.Entry(record).State = EntityState.Modified; } errors = SaveChanges(Language); if (errors.Count > 0) { message = errors.First().errors.First().message; } if (model.book) { WfViewModel wf = new WfViewModel() { Source = "Training", SourceId = CompanyId, DocumentId = PeopleTrainObj.Id, RequesterEmpId = PeopleTrainObj.EmpId, ApprovalStatus = 2, CreatedUser = UserName, }; var wfTrans = _hrUnitOfWork.ComplaintRepository.AddWorkFlow(wf, Language); if (wfTrans == null && wf.WorkFlowStatus != "Success") { PeopleTrainObj.ApprovalStatus = 2; message = wf.WorkFlowStatus; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } errors = SaveChanges(Language); } return(Json(message)); } return(Json(Models.Utils.ParseFormErrors(ModelState))); }
public ActionResult Details(PeopleTrainFormViewModel model, OptionsViewModel moreInfo) { List <Error> errors = new List <Error>(); if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.SiteRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "PeopleTrains", TableName = "PeopleTrain", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), Culture = Language }); if (errors.Count() > 0) { foreach (var e in errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } var record = _hrUnitOfWork.Repository <PeopleTraining>().FirstOrDefault(a => a.Id == model.Id); //insert if (record == null) { record = new PeopleTraining(); AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "PeopleTrains", Options = moreInfo, Transtype = TransType.Insert }); record.CreatedUser = UserName; record.CreatedTime = DateTime.Now; record.CompanyId = CompanyId; record.ApprovalStatus = 6; // record.ApprovalStatus = (byte)(model.submit == true ? 2 : 1); //1- New, 2- Submit record.RequestDate = DateTime.Now; _hrUnitOfWork.TrainingRepository.Add(record); } //update else { AutoMapper(new Models.AutoMapperParm { Destination = record, Source = model, ObjectName = "PeopleTrains", Options = moreInfo, Transtype = TransType.Update }); //if (model.submit) // _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() // { // ColumnName = "ApprovalStatus", // CompanyId = CompanyId, // ObjectName = "PeopleTrains", // SourceId = record.Id, // UserName = UserName, // Version = 0, // ValueAfter = MsgUtils.Instance.Trls("Submit"), // ValueBefore = MsgUtils.Instance.Trls("Darft") // }); record.ModifiedTime = DateTime.Now; record.ModifiedUser = UserName; record.CompanyId = CompanyId; record.RequestDate = DateTime.Now; record.ApprovalStatus = 6; // record.ApprovalStatus = (byte)(model.submit == true ? 2 : model.ApprovalStatus); _hrUnitOfWork.TrainingRepository.Attach(record); _hrUnitOfWork.TrainingRepository.Entry(record).State = EntityState.Modified; } var Errors = SaveChanges(Language); var message = "OK"; if (Errors.Count > 0) { message = Errors.First().errors.First().message; } return(Json(message)); } return(Json(Models.Utils.ParseFormErrors(ModelState))); }
public ActionResult TrainFollowUpDetails(PeopleTrainFormViewModel model, OptionsViewModel moreInfo) { List <Error> Errors = new List <Error>(); PeopleTraining request = _hrUnitOfWork.TrainingRepository.GetPeopleTraining(model.Id); if (ModelState.IsValid) { if (ServerValidationEnabled) { Errors = _hrUnitOfWork.LeaveRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "PeopleTrainFollowUpForm", TableName = "PeopleTrain", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "EventId", Culture = Language }); if (Errors.Count() > 0) { foreach (var e in Errors) { foreach (var errorMsg in e.errors) { ModelState.AddModelError(errorMsg.field, errorMsg.message); } } return(Json(Models.Utils.ParseFormErrors(ModelState))); } } } else { return(Json(Models.Utils.ParseFormErrors(ModelState))); } AutoMapper(new Models.AutoMapperParm { Destination = request, Source = model, ObjectName = "PeopleTrainFollowUpForm", Options = moreInfo }); if (request.ApprovalStatus != 9) { request.RejectDesc = null; request.RejectReason = null; } request.ModifiedTime = DateTime.Now; request.ModifiedUser = UserName; if (request.ApprovalStatus == 5 || request.ApprovalStatus == 9) //Accepted or Rejected { string msg = AddWFTrans(request, null, null); if (msg.Length > 0) { return(Json(msg)); } } _hrUnitOfWork.TrainingRepository.Attach(request); _hrUnitOfWork.TrainingRepository.Entry(request).State = EntityState.Modified; Errors = SaveChanges(Language); if (Errors.Count > 0) { var message = Errors.First().errors.First().message; return(Json(message)); } return(Json("OK")); }
public ActionResult CancelReq(int Id, short?Reason, string Desc) { PeopleTraining PTrainObj = _hrUnitOfWork.TrainingRepository.GetPeopleTraining(Id); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "CancelReason", CompanyId = CompanyId, ObjectName = "PeopleTrainFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = _hrUnitOfWork.LookUpRepository.GetLookUpCodes("CancelReason", Language).Where(a => a.CodeId == Reason).Select(b => b.Title).FirstOrDefault(), ValueBefore = _hrUnitOfWork.LookUpRepository.GetLookUpUserCodes("CancelReason", Language).Where(a => a.CodeId == PTrainObj.CancelReason).Select(b => b.Title).FirstOrDefault() }); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "CancelDesc", CompanyId = CompanyId, ObjectName = "PeopleTrainFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = Desc, ValueBefore = PTrainObj.CancelDesc }); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "PeopleTrainFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = MsgUtils.Instance.Trls("Cancel before approved"), ValueBefore = MsgUtils.Instance.Trls("Submit") }); PTrainObj.CancelDesc = Desc; PTrainObj.CancelReason = Reason; PTrainObj.ApprovalStatus = 7; string error = AddWFTrans(PTrainObj, null, null); if (error.Length > 0) { return(Json(error)); } _hrUnitOfWork.TrainingRepository.Attach(PTrainObj); _hrUnitOfWork.TrainingRepository.Entry(PTrainObj).State = EntityState.Modified; var Errors = SaveChanges(Language); if (Errors.Count > 0) { error = Errors.First().errors.First().message; return(Json(error)); } return(Json("Ok")); }
public IHttpActionResult SaveTrainEvent(TrainEventFormViewModel model) { List <Model.ViewModel.Error> errors = new List <Model.ViewModel.Error>(); if (!ModelState.IsValid) { return(Json(Utils.ParseFormError(ModelState))); } string message = "Ok"; PeopleTraining PeopleTrainObj = new PeopleTraining(); TrainEvent record = _hrUnitOfWork.Repository <TrainEvent>().FirstOrDefault(a => a.Id == model.Id); if (model.PersonId != null) { PeopleTrainObj.EmpId = model.PersonId.GetValueOrDefault(); } else { PeopleTrainObj.EmpId = 1042; } PeopleTrainObj.EmpId = User.Identity.GetEmpId(); PeopleTrainObj.CreatedUser = User.Identity.Name; PeopleTrainObj.CreatedTime = DateTime.Now; PeopleTrainObj.CompanyId = User.Identity.GetDefaultCompany(); PeopleTrainObj.ApprovalStatus = 2; PeopleTrainObj.RequestDate = DateTime.Now; PeopleTrainObj.CourseEDate = model.TrainEndDate; PeopleTrainObj.CourseSDate = model.TrainStartDate; PeopleTrainObj.EventId = record.Id; PeopleTrainObj.CompanyId = User.Identity.GetDefaultCompany(); PeopleTrainObj.Cost = record.Cost; PeopleTrainObj.Curr = record.Curr; PeopleTrainObj.CurrRate = record.CurrRate; PeopleTrainObj.Notes = record.Notes; PeopleTrainObj.CourseId = record.CourseId; PeopleTrainObj.Adwarding = record.Adwarding; _hrUnitOfWork.TrainingRepository.Add(PeopleTrainObj); errors = SaveChanges(User.Identity.GetLanguage()); if (errors.Count > 0) { message = errors.First().errors.First().message; } if (model.book) { WfViewModel wf = new WfViewModel() { Source = "Training", SourceId = User.Identity.GetDefaultCompany(), DocumentId = PeopleTrainObj.Id, RequesterEmpId = PeopleTrainObj.EmpId, ApprovalStatus = 2, CreatedUser = User.Identity.Name, }; var wfTrans = _hrUnitOfWork.ComplaintRepository.AddWorkFlow(wf, User.Identity.GetLanguage()); if (wfTrans == null && wf.WorkFlowStatus != "Success") { PeopleTrainObj.ApprovalStatus = 2; message = wf.WorkFlowStatus; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } errors = SaveChanges(User.Identity.GetLanguage()); } return(Ok(message)); }