public async Task <List <CommentRequest> > GetCommentsbyComplaint(ComplainRequest denuncia) { try { var request = JsonConvert.SerializeObject(denuncia); var content = new StringContent(request, Encoding.UTF8, "application/json"); var client = new HttpClient(); client.BaseAddress = new Uri(Constants.ServiceUrl); var url = Constants.Comments + "byComplaint"; var response = await client.PostAsync(url, content); if (!response.IsSuccessStatusCode) { return(null); } var result = await response.Content.ReadAsStringAsync(); if (result != null) { var Comentarios = JsonConvert.DeserializeObject <List <CommentRequest> >(result); return(Comentarios); } else { return(null); } } catch (Exception ex) { return(null); throw; } }
public CommentView(ComplainRequest _denuncia) { InitializeComponent(); viewModel = new CommentViewModel(_denuncia); viewModel.Navigation = this.Navigation; this.BindingContext = viewModel; }
private async void OnTapped(object obj) { ComplainRequest denuncia = (ComplainRequest)obj; await Navigation.PushAsync(new CommentView(denuncia)); Debug.WriteLine("hola"); }
private string AddWFTrans(ComplainRequest request, int?ManagerId, bool?backToEmp) { WfViewModel wf = new WfViewModel() { Source = "Complaint" + request.Against, SourceId = CompanyId, DocumentId = request.Id, RequesterEmpId = request.EmpId, ApprovalStatus = request.ApprovalStatus, CreatedUser = UserName, }; if (ManagerId != null) { wf.ManagerId = ManagerId; } else if (backToEmp != null) { wf.BackToEmployee = backToEmp.Value; } var wfTrans = _hrUnitOfWork.LeaveRepository.AddWorkFlow(wf, Language); request.WFlowId = wf.WFlowId; if (wfTrans == null && wf.WorkFlowStatus != "Success") { return(wf.WorkFlowStatus); } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } return(""); }
private async void OnTapped2(object obj) { ComplainRequest denuncia = (ComplainRequest)obj; await Navigation.PushAsync(new ProfileView(false, denuncia.IdUser)); Debug.WriteLine("hola"); }
public ActionResult DeleteComplaint(int id) { var message = "OK"; List <Error> errors = new List <Error>(); ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(id); if (request.ApprovalStatus == 1) { AutoMapper(new Models.AutoMapperParm { Source = request, ObjectName = "ComplainRequests", Transtype = TransType.Delete }); _hrUnitOfWork.ComplaintRepository.Remove(request); } errors = SaveChanges(Language); if (errors.Count() > 0) { message = errors.First().errors.First().message; return(Json(message)); } else { return(Json(message)); } }
public CommentViewModel(ComplainRequest denuncia) { this.denuncia = denuncia; initComment(); addCommentCommand = new Command(async() => await ExecuteAddCommentCommand()); RefreshComments = new Command(async() => await ExecuteUpdateList()); }
public ActionResult SendTo(int Id, byte?Send, int?ManagerId) { ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(Id); string error = ""; if (Send == 1) { _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "ComplaintReqFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = MsgUtils.Instance.Trls("EmployeeReview"), ValueBefore = MsgUtils.Instance.Trls("Submit") }); request.ApprovalStatus = 3; error = AddWFTrans(request, null, true); } else if (Send == 2) { _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "ComplaintReqFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = MsgUtils.Instance.Trls("ManagerReview"), ValueBefore = MsgUtils.Instance.Trls("Submit") }); request.ApprovalStatus = 4; error = AddWFTrans(request, ManagerId, null); } if (error.Length > 0) { return(Json(error)); } _hrUnitOfWork.ComplaintRepository.Attach(request); _hrUnitOfWork.ComplaintRepository.Entry(request).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 DeleteComplaint(int id) { string message = "Ok"; ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(id); if (request.ApprovalStatus == 1) { _hrUnitOfWork.ComplaintRepository.Remove(request); message = "Ok"; } else { message = "CantDelete"; } var errors = SaveChanges(User.Identity.GetLanguage()); if (errors.Count() > 0) { message = errors.First().errors.First().message; } return(Ok(message)); }
public IHttpActionResult SaveComplaint(ComplaintRequestViewModel model) { List <Model.ViewModel.Error> errors = new List <Model.ViewModel.Error>(); if (!ModelState.IsValid) { return(Json(Utils.ParseFormError(ModelState))); } // return Ok(ModelState); model.EmpId = User.Identity.GetEmpId(); model.EmpId = 1027; ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(model.Id); string message = "Ok"; ///Save if (model.Id == 0) { /// New request = new ComplainRequest(); AutoMapperParm parms = new AutoMapperParm() { Source = model, Destination = request }; AutoMapper(parms); request.ApprovalStatus = (byte)(model.submit == true ? 2 : 1); //1- New, 2- Submit request.CreatedUser = User.Identity.Name; request.CreatedTime = DateTime.Now; request.RequestDate = DateTime.Now; request.CompanyId = User.Identity.GetDefaultCompany(); _hrUnitOfWork.ComplaintRepository.Add(request); } else if (model.ApprovalStatus == 3 || model.ApprovalStatus == 1) { /// Edit AutoMapperParm parms = new AutoMapperParm() { Source = model, Destination = request }; AutoMapper(parms); if (model.submit) { _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = User.Identity.GetDefaultCompany(), ObjectName = "ComplainRequests", SourceId = request.Id.ToString(), UserName = User.Identity.Name, Version = 0, ValueAfter = MsgUtils.Instance.Trls("Submit"), ValueBefore = MsgUtils.Instance.Trls("Darft") }); } request.ApprovalStatus = (byte)(model.submit == true ? 2 : model.ApprovalStatus); //1- New, 2- Submit request.ModifiedUser = User.Identity.Name; request.ModifiedTime = DateTime.Now; request.RequestDate = DateTime.Now; _hrUnitOfWork.ComplaintRepository.Attach(request); _hrUnitOfWork.ComplaintRepository.Entry(request).State = EntityState.Modified; } var Errors = SaveChanges(User.Identity.GetLanguage()); if (Errors.Count > 0) { message = Errors.First().errors.First().message; return(Ok(message)); } if (model.submit) { WfViewModel wf = new WfViewModel() { Source = "Complaint" + model.Against, SourceId = User.Identity.GetDefaultCompany(), DocumentId = request.Id, RequesterEmpId = request.EmpId, ApprovalStatus = 2, CreatedUser = User.Identity.Name, }; var wfTrans = _hrUnitOfWork.ComplaintRepository.AddWorkFlow(wf, User.Identity.GetLanguage()); if (wfTrans == null && wf.WorkFlowStatus != "Success") { request.ApprovalStatus = 1; message = wf.WorkFlowStatus; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } } Errors = SaveChanges(User.Identity.GetLanguage()); if (Errors.Count > 0) { message = Errors.First().errors.First().message; } return(Ok(message)); }
public ActionResult SaveComplaint(ComplaintRequestViewModel model, OptionsViewModel moreInfo) { List <Error> errors = new List <Error>(); if (ModelState.IsValid) { if (ServerValidationEnabled) { errors = _hrUnitOfWork.CompanyRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "ComplainRequests", TableName = "ComplainRequests", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "CompanyId", 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))); } ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(model.Id); byte version; byte.TryParse(Request.Form["version"], out version); string message = "OK"; ///Save if (model.Id == 0) { /// New request = new ComplainRequest(); AutoMapperParm parms = new AutoMapperParm() { Source = model, Destination = request, Version = version, ObjectName = "ComplainRequests", Options = moreInfo, Transtype = TransType.Insert }; AutoMapper(parms); request.ApprovalStatus = (byte)(model.submit == true ? 2 : 1); //1- New, 2- Submit request.CreatedUser = UserName; request.CreatedTime = DateTime.Now; request.RequestDate = DateTime.Now; request.CompanyId = CompanyId; _hrUnitOfWork.ComplaintRepository.Add(request); } else if (model.ApprovalStatus == 3 || model.ApprovalStatus == 1) { /// Edit AutoMapperParm parms = new AutoMapperParm() { Source = model, Destination = request, Version = version, ObjectName = "ComplainRequests", Options = moreInfo, Transtype = TransType.Update }; AutoMapper(parms); if (model.submit) { _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "ComplainRequests", SourceId = request.Id.ToString(), UserName = UserName, Version = 0, ValueAfter = MsgUtils.Instance.Trls("Submit"), ValueBefore = MsgUtils.Instance.Trls("Darft") }); } request.ApprovalStatus = (byte)(model.submit == true ? 2 : model.ApprovalStatus); //1- New, 2- Submit request.ModifiedUser = UserName; request.ModifiedTime = DateTime.Now; request.RequestDate = DateTime.Now; request.CompanyId = CompanyId; _hrUnitOfWork.ComplaintRepository.Attach(request); _hrUnitOfWork.ComplaintRepository.Entry(request).State = EntityState.Modified; } var Errors = SaveChanges(Language); if (Errors.Count > 0) { message = Errors.First().errors.First().message; return(Json(message)); } if (model.submit) { var chkWorkFlow = _hrUnitOfWork.Repository <Workflow>().Where(w => w.Source == "Complaint" + model.Against).Select(a => a.IsRequired).FirstOrDefault(); if (chkWorkFlow == true) { WfViewModel wf = new WfViewModel() { Source = "Complaint" + model.Against, SourceId = CompanyId, DocumentId = request.Id, RequesterEmpId = request.EmpId, ApprovalStatus = 2, CreatedUser = UserName, }; var wfTrans = _hrUnitOfWork.ComplaintRepository.AddWorkFlow(wf, Language); if (wfTrans == null && wf.WorkFlowStatus != "Success") { request.ApprovalStatus = 1; message = wf.WorkFlowStatus; } else if (wfTrans != null) { _hrUnitOfWork.LeaveRepository.Add(wfTrans); } } else { request.ApprovalStatus = 1; _hrUnitOfWork.ComplaintRepository.Attach(request); _hrUnitOfWork.ComplaintRepository.Entry(request).State = EntityState.Modified; } } Errors = SaveChanges(Language); if (Errors.Count > 0) { message = Errors.First().errors.First().message; } else { message += "," + ((new JavaScriptSerializer()).Serialize(request)); } return(Json(message)); }
public ActionResult CancelReq(int Id, short?Reason, string Desc) { ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(Id); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "CancelReason", CompanyId = CompanyId, ObjectName = "ComplaintReqFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = _hrUnitOfWork.LookUpRepository.GetLookUpCodes("CompCancelReason", Language).Where(a => a.CodeId == Reason).Select(b => b.Title).FirstOrDefault(), ValueBefore = _hrUnitOfWork.LookUpRepository.GetLookUpUserCodes("CompCancelReason", Language).Where(a => a.CodeId == request.CancelReason).Select(b => b.Title).FirstOrDefault() }); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "CancelDesc", CompanyId = CompanyId, ObjectName = "ComplaintReqFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = Desc, ValueBefore = request.CancelDesc }); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "ApprovalStatus", CompanyId = CompanyId, ObjectName = "ComplaintReqFollowUpForm", SourceId = Id.ToString(), UserName = UserName, Version = Convert.ToByte(Request.Form["Version"]), ValueAfter = MsgUtils.Instance.Trls("Cancel before approved"), ValueBefore = MsgUtils.Instance.Trls("Submit") }); request.CancelDesc = Desc; request.CancelReason = Reason; request.ApprovalStatus = 7; string error = AddWFTrans(request, null, null); if (error.Length > 0) { return(Json(error)); } _hrUnitOfWork.ComplaintRepository.Attach(request); _hrUnitOfWork.ComplaintRepository.Entry(request).State = EntityState.Modified; var Errors = SaveChanges(Language); if (Errors.Count > 0) { error = Errors.First().errors.First().message; return(Json(error)); } return(Json("Ok")); }
public ActionResult SaveFollowupDetails(ComplaintRequestViewModel model, OptionsViewModel moreInfo) { List <Error> Errors = new List <Error>(); ComplainRequest request = _hrUnitOfWork.ComplaintRepository.Get(model.Id); if (ModelState.IsValid) { if (ServerValidationEnabled) { Errors = _hrUnitOfWork.LeaveRepository.CheckForm(new CheckParm { CompanyId = CompanyId, ObjectName = "ComplaintReqFollowUpForm", TableName = "ComplainRequests", Columns = Models.Utils.GetColumnViews(ModelState.Where(a => !a.Key.Contains('.'))), ParentColumn = "CompanyId", 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 = "ComplaintReqFollowUpForm", Options = moreInfo, Transtype = TransType.Update }); 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.ComplaintRepository.Attach(request); _hrUnitOfWork.ComplaintRepository.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")); }