public DirectResult Approve(docConfirmation docConfirmation) { try { int currentEmployeeId = 0; var objUser = (coreUser)Session[Constants.CurrentUser]; if (objUser != null && objUser.EmployeeId != null) { currentEmployeeId = (int)objUser.EmployeeId; } var objJobOrder = _jobOrderHeader.Get(j => j.Id == docConfirmation.Id); if (docConfirmation.Type == Constants.DOCUMENT_CONFIRM) { objJobOrder.ApprovedById = currentEmployeeId; objJobOrder.ApprovalDate = DateTime.Now; _context.SaveChanges(); var userOPMapping = _userOperationMapping.GetAll().Where(p => p.OperationTypeId == objJobOrder.OperationTypeId); foreach (var uom in userOPMapping) { //Send to notification table _notification.AddNew(new iffsNotification { Operation = Constants.NTF_OPN_JOB_ORDER, ObjectId = objJobOrder.Id, ActorId = uom.UserId, Date = DateTime.Now, Message = Constants.NTF_OPN_MESSAGE_APPROVED, IsViewed = false }); } return(this.Json(new { success = true, data = "Record successfully approved!" })); } else { //Send to notification table _notification.AddNew(new iffsNotification { Operation = Constants.NTF_OPN_JOB_ORDER, ObjectId = objJobOrder.Id, ActorId = objJobOrder.PreparedById, Date = DateTime.Now, Message = docConfirmation.Comment, IsViewed = false }); return(this.Json(new { success = false, data = "Reject notification sent for a person who prepares the selected document!" })); } } catch (Exception exception) { return(this.Json(new { success = false, data = exception.Message })); } }
public DirectResult Approve(docConfirmation docConfirmation) { try { int currentEmployeeId = 0; var objUser = (coreUser)Session[Constants.CurrentUser]; if (objUser != null && objUser.EmployeeId != null) { currentEmployeeId = (int)objUser.EmployeeId; } var objInvoice = _invoiceHeader.Get(j => j.Id == docConfirmation.Id); if (docConfirmation.Type == Constants.DOCUMENT_CONFIRM) { objInvoice.ApprovedById = currentEmployeeId; objInvoice.ApprovalDate = DateTime.Now; _context.SaveChanges(); return(this.Json(new { success = true, data = "Record successfully checked!" })); } else { //Send to notification table _notification.AddNew(new iffsNotification { Operation = Constants.NTF_OPN_QUOTATION, ObjectId = objInvoice.Id, ActorId = objInvoice.PreparedById, Date = DateTime.Now, Message = docConfirmation.Comment, IsViewed = false }); return(this.Json(new { success = false, data = "Reject notification sent for a person who prepares the selected document!" })); } } catch (Exception exception) { return(this.Json(new { success = false, data = exception.Message })); } }