Beispiel #1
0
 private PeopleContactTask GetTrackingEmailSentTask()
 {
     DateTime maxDate = Presented.GetValueOrDefault(DateTime.Today);
     var peopleContactTask = new PeopleContactTask
     {
         FieldName = BaseCache.TrackingEmailSentField,
         PeopleContactId = PeopleContactId,
         PeopleContactTaskType = DateTime.Today <= maxDate ? PeopleContactTaskType.Actual : PeopleContactTaskType.Delayed,
         RegistrarId = RegistrarId,
         Text = String.Format(ViewResource.PeopleContact_GetTrackingEmailSentTask_Text, LastName, FirstName),
         UseMail = Registrar.UseMail,
         Email1 = Registrar.Email1,
         UseSms = Registrar.UseSms,
         SmsEmail = Registrar.SmsEmail
     };
     return peopleContactTask;
 }
        public async Task<ActionResult> EditTask(PeopleContactTask peopleContactTask, CancellationToken cancellationToken)
        {
            if (peopleContactTask.RegistrarId != UserId)
                return RedirectToAccessDenied();

            PeopleContact peopleContact = PeopleContactCache.GetDetailWithRegister(Db, peopleContactTask.PeopleContactId);
            if (peopleContact.RegistrarId != UserId)
                return RedirectToAccessDenied();

            var previousPeopleContact = new PeopleContact();
            previousPeopleContact.CopyFrom(peopleContact);

            PeopleContactTask tempPeopleContactTask = peopleContact.GetPeopleContactTasks(peopleContactTask.FieldName);
            peopleContactTask.Text = tempPeopleContactTask.Text;

            if (peopleContactTask.FieldValue == null)
            {
                ModelState.AddModelError(BaseCache.FieldValueField, String.Format(ValidationResource.Global_Required_ErrorMessage, FieldResource.Global_Date_Name));
            }
            else
            {
                switch (peopleContactTask.FieldName)
                {
                    case BaseCache.TrackingEmailSentField:
                        peopleContact.TrackingEmailSent = true;
                        if (peopleContact.Presented != null && (peopleContactTask.FieldValue < peopleContact.Presented.Value || peopleContactTask.FieldValue > DateTime.Today))
                        {
                            ModelState.AddModelError(BaseCache.FieldValueField, ValidationResource.PeopleContact_TrackingEmailSentAndPresentedComparing_ErrorMessage);
                        }
                        break;

                    case BaseCache.SecondContactedField:
                        peopleContact.SecondContacted = peopleContactTask.FieldValue;
                        if (peopleContact.Presented != null && (peopleContactTask.FieldValue < peopleContact.Presented.Value || peopleContactTask.FieldValue > DateTime.Today))
                        {
                            ModelState.AddModelError(BaseCache.FieldValueField, ValidationResource.PeopleContact_SecondContactedAndPresentedComparing_ErrorMessage);
                        }
                        break;

                    case BaseCache.SecondTrackingEmailSentField:
                        peopleContact.SecondTrackingEmailSent = true;
                        if (peopleContact.SecondContacted != null && (peopleContactTask.FieldValue < peopleContact.SecondContacted.Value || peopleContactTask.FieldValue > DateTime.Today))
                        {
                            ModelState.AddModelError(BaseCache.FieldValueField, ValidationResource.PeopleContact_SecondTrackingEmailSentAndSecondContactedComparing_ErrorMessage);
                        }
                        break;

                    case BaseCache.BusinessInfoParticipatedField:
                        peopleContact.BusinessInfoParticipated = peopleContactTask.FieldValue;
                        if (peopleContact.Presented != null && (peopleContactTask.FieldValue < peopleContact.Presented.Value || peopleContactTask.FieldValue > DateTime.Today))
                        {
                            ModelState.AddModelError(BaseCache.FieldValueField, ValidationResource.PeopleContact_BusinessInfoParticipatedAndPresentedComparing_ErrorMessage);
                        }
                        break;

                    case BaseCache.SecondMeetingField:
                        peopleContact.SecondMeeting = peopleContactTask.FieldValue;
                        if (peopleContact.SecondContacted != null && (peopleContactTask.FieldValue < peopleContact.SecondContacted.Value || peopleContactTask.FieldValue > DateTime.Today))
                        {
                            ModelState.AddModelError(BaseCache.FieldValueField, ValidationResource.PeopleContact_SecondMeetingAndSecondContactedComparing_ErrorMessage);
                        }
                        break;

                    case BaseCache.ThirdMeetingField:
                        peopleContact.ThirdMeeting = peopleContactTask.FieldValue;
                        if (peopleContact.BusinessInfoParticipated != null && (peopleContactTask.FieldValue < peopleContact.BusinessInfoParticipated.Value || peopleContactTask.FieldValue > DateTime.Today))
                        {
                            ModelState.AddModelError(BaseCache.FieldValueField, ValidationResource.PeopleContact_ThirdMeetingAndBusinessInfoParticipatedComparing_ErrorMessage);
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            if (ModelState.IsValid)
            {
                var calendar = new Calendar
                {
                    GoogleCredentialsJson = peopleContact.Registrar.GoogleCredentialsJson,
                    GoogleCalendarId = peopleContact.Registrar.GoogleCalendarId,
                    UseGoogleCalendarByUser = peopleContact.Registrar.UseGoogleCalendar,
                    UseMail = peopleContact.Registrar.UseMail,
                    EmailTo = peopleContact.Registrar.Email1,
                    ReminderTime = peopleContact.Registrar.ReminderTime,
                    IsEventsPrivate = peopleContact.Registrar.IsEventsPrivate
                };
                await calendar.AuthorizeAsync(this, cancellationToken);
                CheckWorkflow(peopleContact, previousPeopleContact, calendar);

                Db.Entry(peopleContact).State = EntityState.Modified;
                Db.SaveChanges();

                return View("EditTaskSummary", "_PopupLayout", peopleContactTask);
            }

            return View("EditTask", "_PopupLayout", peopleContactTask);
        }
Beispiel #3
0
 private PeopleContactTask GetThirdMeetingTask()
 {
     DateTime minDate = BusinessInfoParticipated.GetValueOrDefault(DateTime.Today).AddDays(2);
     DateTime maxDate = minDate.AddDays(2);
     var peopleContactTask = new PeopleContactTask
     {
         FieldName = BaseCache.ThirdMeetingField,
         PeopleContactId = PeopleContactId,
         PeopleContactTaskType = DateTime.Today <= maxDate ? PeopleContactTaskType.Actual : PeopleContactTaskType.Delayed,
         RegistrarId = RegistrarId,
         Text = String.Format(ViewResource.PeopleContact_GetThirdMeetingTask_Text, LastName, FirstName, minDate.ToString("dd.MM.yyyy")),
         UseMail = Registrar.UseMail,
         Email1 = Registrar.Email1,
         UseSms = Registrar.UseSms,
         SmsEmail = Registrar.SmsEmail
     };
     return peopleContactTask;
 }