public IHttpActionResult GetTaskById(int?TaskId) { var response = new DataResponse <EntityTask>(); var repository = new RepositoryTask(); if (TaskId.HasValue) { response = repository.GetTaskById(TaskId.Value, CurrentUserId, CurrentBusinessId); if (response.Model != null) { //response.Model.CreatedOn = response.Model.CreatedOn.ToLocalTime(); if (response.Model.TargetDate.HasValue) { response.Model.TargetDate = response.Model.TargetDate.Value.ToLocalTime(); } if (response.Model.AlertDate.HasValue) { response.Model.AlertDate = response.Model.AlertDate.Value.ToLocalTime(); } } } else { response.Model = new EntityTask(); } return(Ok <DataResponse>(response)); }
public IHttpActionResult GetTaskById(int?TaskId) { var response = new DataResponse <EntityTask>(); var repository = new RepositoryTask(); if (TaskId.HasValue) { response = repository.GetTaskById(TaskId.Value, CurrentUserId, CurrentBusinessId, true); } else { response.Model = new EntityTask(); } return(Ok <DataResponse>(response)); }
private void SendEmailNotification(string returnUrl, int taskId) { var repository = new RepositoryTask(); var objTask = repository.GetTaskById(taskId, CurrentUserId, CurrentBusinessId); EntityTask model = objTask.Model; var CreatedByName = CurrentUser.FirstName + " " + CurrentUser.LastName; var ReturnUrl = ConfigurationManager.AppSettings["BaseUrl"] + CurrentUser.BusinessName.Replace(" ", "-") + "#/tasks/" + model.ReferenceNumber; var rootPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; var Subject = "Task " + model.ReferenceNumber + " - " + model.Subject + ""; var mail = new GMEmail(); string toEmails = null, practiceName = null, priorityType = null, targetDate = null, status = null; if (model.PracticeId.HasValue) { practiceName = new RepositoryLookups().GetPracticeNameById(model.PracticeId.Value); } if (model.PriorityTypeId.HasValue) { priorityType = EnumHelper.GetEnumName <TaskPriorities>(model.PriorityTypeId.Value); } targetDate = model.TargetDate.HasValue ? model.TargetDate.ToString() : "Not Set"; var AssignedUsers = string.Join(",", model.AssignedUsersList.Select(a => a.Name)); if (!string.IsNullOrEmpty(returnUrl)) { returnUrl += model.ReferenceNumber; } if (model.StatusId.HasValue) { status = Regex.Replace(EnumHelper.GetEnumName <TaskStatuses>(model.StatusId.Value), "([A-Z]{1,2}|[0-9]+)", " $1").Trim(); } if (CurrentUserId != model.RequestedUser.UserId) { var emailBody = TemplateManager.UpdateOrDeleteTask(rootPath, model.RequestedUser.Name, null, CreatedByName, model.Subject, targetDate, model.TaskDescription, practiceName, priorityType, status, ReturnUrl, false, CurrentBusinessId.Value, CurrentUser.RelativeUrl); mail.SendDynamicHTMLEmail(model.RequestedUser.Email, Subject, emailBody, CurrentUser.OtherEmails); } foreach (var item in model.AssignedUsersList) { if (item.UserId == CurrentUserId) { continue; } toEmails = new RepositoryUserProfile().NotificationEnabledEmails(item.Email, "TSKSTATNFN"); if (!string.IsNullOrEmpty(toEmails)) { var emailBody = TemplateManager.UpdateOrDeleteTask(rootPath, item.Name, null, CreatedByName, model.Subject, targetDate, model.TaskDescription, practiceName, priorityType, status, ReturnUrl, false, CurrentBusinessId.Value, CurrentUser.RelativeUrl); mail.SendDynamicHTMLEmail(toEmails, Subject, emailBody, CurrentUser.OtherEmails); } } foreach (var item in model.WatchersList) { toEmails = new RepositoryUserProfile().NotificationEnabledEmails(item.Email, "TSKSTATNFN"); if (!string.IsNullOrEmpty(toEmails)) { var emailBody = TemplateManager.UpdateOrDeleteTask(rootPath, item.Name, AssignedUsers, CreatedByName, model.Subject, targetDate, model.TaskDescription, practiceName, priorityType, status, ReturnUrl, true, CurrentBusinessId.Value, CurrentUser.RelativeUrl); mail.SendDynamicHTMLEmail(toEmails, Subject, emailBody, CurrentUser.OtherEmails); } } }