Пример #1
0
        public ICollection <ActivityDate> dates = new List <ActivityDate>(); // Liste für Einzeltermine

        /// <summary>
        ///
        /// </summary>
        /// <param name="event"></param>
        /// <param name="model"></param>
        public EventHelpers(Event @event, EventCreateSeriesModel model)
        {
            // Übertragung des Models
            this.model = model;

            // Übertragung der Termine
            start = model.Day.AddHours(model.StartTimeHour).AddMinutes(model.StartTimeMinute);
            if (model.endType == "useEndDate")
            {
                end = model.EndDay.AddHours(model.EndTimeHour).AddMinutes(model.EndTimeMinute);
            }
            else
            {
                if (model.endType == "noEnd")
                {
                    model.countDates = 100; // Maximale Anzahl an Events, wenn "Kein Ende" ausgewählt wurde
                }
                end = new DateTime().AddHours(model.EndTimeHour).AddMinutes(model.EndTimeMinute);
            }

            var firstDate = new ActivityDate {
                Begin = start,
                End   = new DateTime().AddYears(start.Year).AddMonths(start.Month).AddDays(start.Day).AddHours(end.Hour).AddMinutes(end.Minute)
            };

            dates.Add(firstDate);

            // Termine erzeugen
            CreateDates();
        }
Пример #2
0
        public override void AdjustDates(IList <int> ids, int shift, int classId)
        {
            BaseSecurity.EnsureTeacher(Context);

            using (var uow = Update())
            {
                var newDates      = CreateClassAnnouncementDataAccess(uow).AdjustDates(ids, shift, classId);
                var activityDates = ActivityDate.Create(newDates);

                try //Post new dates to iNow. If any conflicts terminate whole operation.
                {
                    ConnectorLocator.ActivityConnector.AdjustDates(activityDates);
                    uow.Commit();
                }
                catch (Exception e)
                {
                    uow.Rollback();
                    if (e.InnerException != null && e.InnerException.Message == InowErrors.ACTIVITY_SECTION_NAME_DATE_MUSTBEUNIQUE_ERROR)
                    {
                        throw new ChalkableException(ChlkResources.ERR_ADJUSTING_ACTIVITIES_DATE_CONFLICT);
                    }
                    throw;
                }
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        public void createDailyDates()
        {
            if (model.endType == "useEndDate")
            {
                start = start.AddDays(model.dailyCount);
                while (start < end)
                {
                    DateTime endDate = new DateTime().AddYears(start.Year).AddMonths(start.Month).AddDays(start.Day).AddHours(end.Hour).AddMinutes(end.Minute);
                    var      date    = new ActivityDate
                    {
                        Begin = start,
                        End   = endDate
                    };

                    dates.Add(date);
                    start = start.AddDays(model.dailyCount);
                }
            }
            else
            {
                for (int i = 2; i <= model.countDates; i++)
                {
                    start = start.AddDays(model.dailyCount);
                    DateTime endDate = new DateTime().AddYears(start.Year).AddMonths(start.Month).AddDays(start.Day).AddHours(end.Hour).AddMinutes(end.Minute);
                    var      date    = new ActivityDate
                    {
                        Begin = start,
                        End   = endDate
                    };

                    dates.Add(date);
                }
            }
        }
Пример #4
0
 public void InsertActivityDate(ActivityDate activityDate)
 {
     using (var db = this.GetDatabase())
     {
         db.ActivityDate.Add(activityDate);
         db.SaveChanges();
     }
 }
Пример #5
0
 public void EditActivityDateById(DateTime date, int id)
 {
     using (var db = this.GetDatabase())
     {
         ActivityDate activityDateDB = db.ActivityDate.SingleOrDefault(activityDate => activityDate.Id == id);
         activityDateDB.Date = date;
         db.SaveChanges();
     }
 }
Пример #6
0
        public static MvcHtmlString Date(this HtmlHelper htmlHelper, ActivityDate courseDate)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("{0} [{1:HH\\:mm} - {2:HH\\:mm}]",
                            courseDate.Begin.ToString("dd. MMMM yyyy", new CultureInfo("de-DE")), courseDate.Begin, courseDate.End);

            return(new MvcHtmlString(sb.ToString()));
        }
Пример #7
0
 public void DeleteActivityDateById(int id)
 {
     using (var db = this.GetDatabase())
     {
         ActivityDate activityDateDB = db.ActivityDate.SingleOrDefault(activityDate => activityDate.Id == id);
         db.ActivityDate.Remove(activityDateDB);
         db.SaveChanges();
     }
 }
Пример #8
0
        internal bool HasSubscription(ActivityDate date, string userId)
        {
            if (date.Slots.Any())
            {
                return(date.Slots.Any(x => x.Occurrence.Subscriptions.Any(s => s.UserId.Equals(userId))));
            }

            return(date.Occurrence.Subscriptions.Any(x => x.UserId.Equals(userId)));
        }
Пример #9
0
        internal ActivitySlot GetSubscribedSlot(ActivityDate date, string userId)
        {
            if (!date.Slots.Any())
            {
                return(null);
            }

            return(date.Slots.FirstOrDefault(x => x.Occurrence.Subscriptions.Any(y => y.UserId.Equals(userId))));
        }
 public IActionResult CreateActivity([Bind("ActivityId,StudentId,Date,Grade,Attendance")] ActivityDate activityDate)
 {
     if (ModelState.IsValid)
     {
         // trebuie modificat si-n model dupa exemplul cu SingleRowActivityInfo
         _teacherServices.AddActivityDate(activityDate);
         return(RedirectToAction(nameof(Index)));
     }
     return(View("Index"));
 }
Пример #11
0
 public void AddActivity(Activity activity)
 {
     ActivityList.Add(activity);
     ActivityPersistency.SaveActivity(activity);
     foreach (var dates in activity.Dates)
     {
         var date = new ActivityDate(activity.ID, dates.ToString());
         DatesPersistency.SaveDates(date);
     }
 }
Пример #12
0
        public UserActivityDate GetUserActivityDateByUserAndActivityDate(ActivityDate activityDate)
        {
            UserActivityDate userActivityDate = this.User.UserActivityDate.SingleOrDefault(
                userActivityDateDB =>
                userActivityDateDB.UserId == this.User.Id &&
                userActivityDateDB.ActivityDateId == activityDate.Id
                );

            return(userActivityDate != null ? userActivityDate : new UserActivityDate());
        }
Пример #13
0
        /// <summary>
        /// Ermittelt den Text für Eintragungen
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public string GetStatusText(ActivityDate date)
        {
            var now = DateTime.Now;

            // nach Beginn keine Anzeige
            if (date.Begin <= now && now <= date.End)
            {
                return("Termin findet gerade statt");
            }
            if (date.End < now)
            {
                return("Termin hat stattgefunden");
            }


            if (!date.Occurrence.FromIsRestricted && !date.Occurrence.UntilIsRestricted)
            {
                // keine Beschränkung
                return("Eintragung jederzeit möglich");
            }

            var sb = new StringBuilder();

            if (date.Occurrence.FromIsRestricted)
            {
                if (date.Occurrence.FromDateTime.HasValue)
                {
                    sb.Append(string.Format("Eintragung ab {0:dd.MM.yyyy HH:mm} offen.", date.Occurrence.FromDateTime.Value));
                }

                if (date.Occurrence.FromTimeSpan.HasValue)
                {
                    var d = date.Begin.AddHours(-date.Occurrence.FromTimeSpan.Value.Hours)
                            .AddMinutes(-date.Occurrence.FromTimeSpan.Value.Minutes);
                    sb.Append(string.Format("Eintragung ab {0:dd.MM.yyyy HH:mm} offen", d));
                }
            }

            if (date.Occurrence.UntilIsRestricted)
            {
                if (date.Occurrence.UntilDateTime.HasValue)
                {
                    sb.Append(string.Format("Eintragung bis {0:dd.MM.yyyy HH:mm} offen.", date.Occurrence.UntilDateTime.Value));
                }

                if (date.Occurrence.UntilTimeSpan.HasValue)
                {
                    var d = date.Begin.AddHours(-date.Occurrence.UntilTimeSpan.Value.Hours)
                            .AddMinutes(-date.Occurrence.UntilTimeSpan.Value.Minutes);
                    sb.Append(string.Format("Eintragung bis {0:dd.MM.yyyy HH:mm} offen", d));
                }
            }

            return(sb.ToString());
        }
 public override string ToString()
 {
     return("[UserActivityLog: " +
            " ID = " + ID.ToString() +
            " UserID = " + UserID +
            " Activity = " + Activity +
            " ActivityType = " + ActivityType +
            " PageUrl = " + PageUrl +
            " ActivityDate = " + ActivityDate.ToString() +
            " Remarks = " + Remarks + "]");
 }
Пример #15
0
        public ActionResult EditDate(ActivityDate model)
        {
            var date = Db.ActivityDates.SingleOrDefault(x => x.Id == model.Id);

            date.Title = model.Title;
            Db.SaveChanges();

            var officeHour = date.Activity as OfficeHour;

            return(RedirectToAction("DateDetails", new{ id = date.Id }));
        }
Пример #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public NextEventContract GetNextEvent(Guid id)
        {
            var db = new TimeTableDbContext();

            var currentEvent = db.Activities.OfType <Event>().SingleOrDefault(ev => ev.Id == id);

            var now = DateTime.Now.AddMinutes(-1);

            // Gib mir von dem Event das Ende des nächsten Termins in der Zukunft
            var currentDate = currentEvent.Dates.Where(d => d.End >= now).OrderBy(d => d.End).FirstOrDefault();

            // Gib mir jetzt das Event, mit dem zeitlich am nächst gelegenen Beginn zum aktuellen Datum
            var eventList =
                db.Activities.OfType <Event>()
                .Where(ev => ev.Published == true && ev.Id != id &&
                       ev.Dates.Any(d => d.End >= currentDate.Begin)).ToList();

            ActivityDate nextDate = null;

            foreach (var @event in eventList)
            {
                var testDate = @event.Dates.Where(d => d.End >= now).OrderBy(d => d.Begin).FirstOrDefault();

                if (nextDate == null)
                {
                    nextDate = testDate;
                }
                else
                {
                    if (testDate.Begin < nextDate.Begin)
                    {
                        nextDate = testDate;
                    }
                }
            }

            if (nextDate == null)
            {
                return(GetNextEvent());
            }


            var nextEvent = new NextEventContract
            {
                EventId     = nextDate.Activity.Id,
                Title       = nextDate.Activity.Name,
                Description = nextDate.Activity.Description,
                From        = nextDate.Begin,
                Location    = nextDate.Rooms.Any() ? nextDate.Rooms.First().Number : string.Empty,
            };

            return(nextEvent);
        }
Пример #17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public NextEventContract GetNextEvent()
        {
            var db = new TimeTableDbContext();

            var now = DateTime.Now;

            var eventList =
                db.Activities.OfType <Event>()
                .Where(ev => ev.Published == true && ev.Dates.Any(d => d.End >= now)).ToList();

            ActivityDate nextDate = null;

            foreach (var @event in eventList)
            {
                var testDate = @event.Dates.Where(d => d.End >= now).OrderBy(d => d.Begin).FirstOrDefault();

                if (nextDate == null)
                {
                    nextDate = testDate;
                }
                else
                {
                    if (testDate.Begin < nextDate.Begin)
                    {
                        nextDate = testDate;
                    }
                }
            }

            if (nextDate != null)
            {
                var nextEvent = new NextEventContract
                {
                    EventId     = nextDate.Activity.Id,
                    Title       = nextDate.Activity.Name,
                    Description = nextDate.Activity.Description,
                    From        = nextDate.Begin,
                    Location    = nextDate.Rooms.Any() ? nextDate.Rooms.First().Number : string.Empty,
                };
                return(nextEvent);
            }
            else
            {
                return(new NextEventContract
                {
                    Title = "Derzeit keine Veranstaltung",
                });
            }
        }
Пример #18
0
        internal ICollection <OccurrenceSubscription> GetSubscriptions(ActivityDate date)
        {
            var list = new List <OccurrenceSubscription>();

            if (date.Slots.Any())
            {
                foreach (var slot in date.Slots)
                {
                    list.AddRange(slot.Occurrence.Subscriptions);
                }
            }

            list.AddRange(date.Occurrence.Subscriptions);

            return(list);
        }
Пример #19
0
        internal OccurrenceSubscription GetSubscription(ActivityDate date, string userId)
        {
            if (date.Slots.Any())
            {
                foreach (var slot in date.Slots)
                {
                    var sub = slot.Occurrence.Subscriptions.FirstOrDefault(x => x.UserId.Equals(userId));
                    if (sub != null)
                    {
                        return(sub);
                    }
                }
                return(null);
            }

            return(date.Occurrence.Subscriptions.FirstOrDefault(x => x.UserId.Equals(userId)));
        }
Пример #20
0
        internal ActivityDateChange CreateActivityDateStateChange(ActivityDate date, bool hasRoomChange)
        {
            var change = new ActivityDateChange
            {
                TimeStamp      = DateTime.Now,
                Date           = date,
                NewBegin       = date.Begin,
                NewEnd         = date.End,
                OldBegin       = date.Begin,
                OldEnd         = date.End,
                HasTimeChange  = false,
                HasStateChange = true,
                HasRoomChange  = hasRoomChange
            };

            return(change);
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        public void createWorkdayDates()
        {
            if (model.endType == "useEndDate")
            {
                start = start.AddDays(1);
                while (start < end)
                {
                    if (start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday)
                    {
                        continue;
                    }

                    DateTime endDate = new DateTime().AddYears(start.Year).AddMonths(start.Month).AddDays(start.Day).AddHours(end.Hour).AddMinutes(end.Minute);
                    var      date    = new ActivityDate
                    {
                        Begin = start,
                        End   = endDate
                    };

                    dates.Add(date);
                    start = start.AddDays(1);
                }
            }
            else
            {
                for (int i = 2; i <= model.countDates; i++)
                {
                    start = start.AddDays(1);

                    if (start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday)
                    {
                        continue;
                    }

                    DateTime endDate = new DateTime().AddYears(start.Year).AddMonths(start.Month).AddDays(start.Day).AddHours(end.Hour).AddMinutes(end.Minute);
                    var      date    = new ActivityDate
                    {
                        Begin = start,
                        End   = endDate
                    };

                    dates.Add(date);
                }
            }
        }
        public async Task <IActionResult> TeacherActivityModify(int?id, [Bind("Id, ActivityId, StudentId, Date, Grade, Attendance")] ActivityDate activityDate)
        {
            if (id == null || !await _auth.IsTeacher(User))
            {
                return(NotFound());
            }

            int activityId = id ?? default(int);

            if (ModelState.IsValid)
            {
                _teacherServices.UpdateActivityDate(activityDate);


                return(RedirectToAction(nameof(Index)));
            }
            return(View("Index"));
        }
Пример #23
0
        internal bool IsExpired(ActivityDate date)
        {
            if (!date.Occurrence.UntilIsRestricted)
            {
                return(date.Begin < DateTime.Now);
            }


            if (date.Occurrence.UntilTimeSpan.HasValue)
            {
                var endOfSubscriptionPeriod =
                    date.Begin.AddHours(-date.Occurrence.UntilTimeSpan.Value.Hours)
                    .AddMinutes(-date.Occurrence.UntilTimeSpan.Value.Minutes);

                return(endOfSubscriptionPeriod < DateTime.Now);
            }

            return(false);
        }
        public async Task <IActionResult> TeacherActivityAdd(int?activityId, int?studentId)
        {
            var result = await _auth.IsUserValid(User);

            if (!result)
            {
                throw new ApplicationException($"Unable to load user");
            }

            if (activityId == null ||
                !await _auth.IsTeacher(User) ||
                studentId == null)
            {
                return(NotFound());
            }

            int idActivityDate = activityId ?? default(int);
            int idStudent      = studentId ?? default(int);

            Student  student  = _teacherServices.GetStudent(idStudent);
            Activity activity = _teacherServices.GetActivity(idActivityDate);

            var activityDate = new ActivityDate()
            {
                ActivityId = activity.Id,
                StudentId  = student.Id,
                Date       = DateTime.Now,
                Grade      = 0,
                Attendance = false
            };

            var model = new SingleStudentActivityInfo
            {
                ActivityDate = activityDate,
                Student      = student,
                Activity     = activity
            };

            return(View(model));
        }
Пример #25
0
        public ActionResult Delete(int id)
        {
            this.allowedRoles.Add(this.ROLE_MANAGER);
            RedirectToRouteResult redirectToHome = this.RouteAccessAllowedRoles();

            if (redirectToHome != null)
            {
                return(redirectToHome);
            }

            ActivityDateManager adm          = new ActivityDateManager();
            ActivityDate        activityDate = adm.GetActivityDateById(id);

            adm.DeleteActivityDateById(id);

            int activityId = (int)activityDate.ActivityId;

            ActivityManager am       = new ActivityManager();
            Activity        activity = am.GetActivityById(activityId);

            return(RedirectToAction("Edit", "Activity", new { id = activity.Id }));
        }
Пример #26
0
        //Gemmer dato
        public static async void SaveDates(ActivityDate date)
        {
            const string      Url     = "http://localhost:55000";
            HttpClientHandler handler = new HttpClientHandler();

            handler.UseDefaultCredentials = true;


            using (var client = new HttpClient(handler))
            {
                client.BaseAddress = new Uri(Url);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                try
                {
                    await client.PostAsJsonAsync("api/DateTables", date);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
Пример #27
0
        public static Activity create_activity(string[] fields, List <Person> persons)
        {
            Activity a = new Activity();

            a.ID          = int.Parse(fields[0]);
            a.name        = fields[1];
            a.description = fields[2];
            ActivityDate ad       = new ActivityDate();
            CultureInfo  provider = new CultureInfo("fr-FR");

            ad.startDate  = DateTime.ParseExact(fields[3], "g", provider);
            ad.finishDate = DateTime.ParseExact(fields[4], "g", provider);
            a.time        = ad;
            for (int i = 5; i < fields.Length; i++)
            {
                int    personID = int.Parse(fields[i]);
                Person p        = persons.Find(person => person.ID == personID);
                if (p != null)
                {
                    a.AddParticipants(p);
                }
            }
            return(a);
        }
Пример #28
0
 // methods
 public override string ToString()
 {
     return($"{Name}-{ActivityDate.ToShortDateString()}");
 }
Пример #29
0
        /*Methods*/
        public override string ToString()
        {
            string shortDate = ActivityDate.ToShortDateString();

            return($"{Name} - {shortDate}");
        }
        private void BuildInterface()
        {
            View.BackgroundColor = new UIImage("Images/fondoPrincipal.jpg").GetScaledImageBackground(View);

            var header = new Header(View.Frame.Width)
            {
                LocationTitle   = _assignmentVm.SelectedAssignment.CompanyName,
                LeftButtonImage = "Images/btn-atras.png",
                ButtonTouch     = async(sender, args) =>
                {
                    if (_assignmentVm.SelectedActivity.ActivityType == Enumerations.ActivityType.None)
                    {
                        _assignmentVm.SelectedAssignment.Activities.Remove(_assignmentVm.SelectedActivity);
                    }
                    else
                    {
                        if (_assignmentVm.SelectedActivity.IsRecording)
                        {
                            await _assignmentVm.StopAsync(willContinue : true);

                            _assignmentVm.SelectedActivity.IsRecording = true;
                        }
                        _assignmentVm.SelectedActivity.Traces.Add(new Trace
                        {
                            ActivityId    = _assignmentVm.SelectedActivity.Id,
                            ActivityState = _assignmentVm.SelectedActivity.State,
                            TraceDate     = DateTime.Now,
                            Longitude     = (decimal)_longitude,
                            Latitude      = (decimal)_latitude
                        });
                        await _assignmentVm.SaveActivityAsync();
                    }
                    _navigationService.GoBack();
                }
            };

            var principalData = new AssignmentDataView(View.Frame)
            {
                Frame = new CGRect(0, header.Frame.Y + header.Frame.Height, View.Frame.Width, 65)
            };

            _activityType = new ActivityFill
            {
                Title           = "Tipo de Actividad",
                BackgroundColor = UIColor.Clear,
                Frame           = new CGRect(10, principalData.Frame.Y + principalData.Frame.Height, View.Frame.Width, 40),
                Hit             = TouchActivityTypeButton
            };

            _description = new ActivityFill
            {
                Title           = "Decripción",
                BackgroundColor = UIColor.Clear,
                Frame           = new CGRect(10, _activityType.Frame.Y + _activityType.Frame.Height, View.Frame.Width - 20, 40),
                Hit             = TouchButtonDescription
            };

            _startDate = new ActivityDate
            {
                Title = "Fecha de Inicio",
                Frame = new CGRect(10, _description.Frame.Y + _description.Frame.Height, View.Frame.Width, 40)
            };

            _endDate = new ActivityDate
            {
                Title = "Fecha de Inicio",
                Frame = new CGRect(10, _startDate.Frame.Y + _startDate.Frame.Height, View.Frame.Width, 40)
            };

            _description.NewTitle = string.IsNullOrEmpty(_assignmentVm.SelectedActivity.Description)
                ? "+"
                : _assignmentVm.SelectedActivity.Description;
            _activityType.NewTitle = GetTypeName(_assignmentVm.SelectedActivity.ActivityType);
            _startDate.Date        = (_assignmentVm.SelectedActivity.StartDate != DateTime.MinValue)
                ? _assignmentVm.SelectedActivity.StartDate.ToString("dd/MM/yyyy hh:mm")
                : string.Empty;
            _endDate.Date = (_assignmentVm.SelectedActivity.EndDate != DateTime.MinValue)
                ? _assignmentVm.SelectedAssignment.EndDate.ToString("dd/MM/yyyy hh:mm")
                : string.Empty;

            if (_assignmentVm.SelectedActivity.IsRecording)
            {
                var elapsed = DateTime.Now - _assignmentVm.SelectedActivity.StartDate;
                _assignmentVm.SelectedActivity.Duration = _assignmentVm.SelectedActivity.Duration.Add(elapsed);
                _assignmentVm.RecordAsync();
            }

            _timerView = new UIView
            {
                Frame = new CGRect(View.Frame.Width / 2 - 70, _endDate.Frame.Y + _endDate.Frame.Height + 10, 160, 160)
            };

            _timespan = new UILabel
            {
                Frame     = new CGRect(0, 0, 160, 60),
                Font      = UIFont.FromName("Helvetica-Bold", 35),
                TextColor = UIColor.White,
                Text      = _assignmentVm.SelectedActivity.Duration.ToString(@"hh\:mm\:ss")
            };

            var timerButton = UIButton.FromType(UIButtonType.Custom);

            timerButton.Frame = new CGRect(View.Frame.Width / 2 - 120, _timespan.Frame.Height + 5, 70, 70);
            timerButton.SetImage(
                _assignmentVm.SelectedActivity.IsRecording
                        ? new UIImage("Images/btn-stop.png")
                        : new UIImage("Images/btn-play.png"), UIControlState.Normal);

            timerButton.Enabled        = _assignmentVm.SelectedAssignment.Status != Enumerations.AssignmentStatus.Complete;
            timerButton.TouchUpInside += (sender, args) =>
            {
                if (_assignmentVm.ActiveActivity != null &&
                    _assignmentVm.SelectedActivity.Id != _assignmentVm.ActiveActivity.Id)
                {
                    new UIAlertView(title: "Ferreyros", message: Constants.Messages.ActivityNotFinished, del: null,
                                    cancelButtonTitle: "OK", otherButtons: null).Show();
                    return;
                }
                _activityType.UserInteractionEnabled = false;
                _description.UserInteractionEnabled  = false;

                timerButton.Enabled          = false;
                _assignmentVm.ActiveActivity = !_assignmentVm.SelectedActivity.IsRecording
                    ? _assignmentVm.SelectedActivity
                    : null;

                var task = _assignmentVm.SelectedActivity.IsRecording
                    ? _assignmentVm.StopAsync()
                    : _assignmentVm.RecordAsync();

                timerButton.SetImage(
                    _assignmentVm.SelectedActivity.IsRecording
                        ? new UIImage("Images/btn-stop.png")
                        : new UIImage("Images/btn-play.png"), UIControlState.Normal);

                task.ContinueWith(_ =>
                {
                    BeginInvokeOnMainThread(() =>
                    {
                        timerButton.Enabled = _assignmentVm.ActiveActivity != null;
                    });
                });
            };
            //_timerView.Hidden = _assignmentVm.SelectedActivity.ActivityType == Enumerations.ActivityType.None;
            _timerView.AddSubviews(timerButton, _timespan);

            var notifyClient = UIButton.FromType(UIButtonType.Custom);

            notifyClient.SetImage(new UIImage("Images/send-mail.png"), UIControlState.Normal);
            notifyClient.SetTitle("Notificar el fin del servicio al Cliente", UIControlState.Normal);
            notifyClient.BackgroundColor          = UIColor.Clear;
            notifyClient.TitleLabel.Font          = UIFont.FromName("Helvetica-Light", 13f);
            notifyClient.TitleLabel.TextAlignment = UITextAlignment.Left;
            notifyClient.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
            notifyClient.TitleEdgeInsets          = new UIEdgeInsets(0, -60, 0, -150);
            notifyClient.Frame = new CGRect(40, _timerView.Frame.Y + _timerView.Frame.Height + 10, 80, 40);
            notifyClient.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            //notifyClient.Enabled = _assignmentVm.SelectedActivity.State != Enumerations.ActivityState.Completed;
            notifyClient.TouchUpInside += (sender, args) =>
            {
                if (_assignmentVm.SelectedActivity.IsRecording)
                {
                    new UIAlertView(title: "Ferreyros", message: Constants.Messages.ActivityNotFinished, del: null,
                                    cancelButtonTitle: "OK", otherButtons: null).Show();
                    return;
                }

                var okCancelAlertController = UIAlertController.Create("Cerrar Servicio",
                                                                       "¿Con esta actividad se ha completado el servicio?, se enviará un correo al cliente informando.",
                                                                       UIAlertControllerStyle.Alert);

                okCancelAlertController.AddAction(UIAlertAction.Create("Si", UIAlertActionStyle.Default, async alert =>
                {
                    _assignmentVm.SelectedActivity.State = Enumerations.ActivityState.Completed;
                    await _assignmentVm.SaveActivityAsync();
                    await _assignmentVm.SendActivityEndsAssignmentMailAsync();
                    notifyClient.Enabled = false;
                }));
                okCancelAlertController.AddAction(UIAlertAction.Create("No", UIAlertActionStyle.Cancel, alert => { }));

                PresentViewController(okCancelAlertController, true, null);
            };

            var copyRight = new UILabel
            {
                Text          = "2016 Ferreyros | Derechos Reservados",
                TextAlignment = UITextAlignment.Center,
                TextColor     = UIColor.White,
                Font          = UIFont.FromName("Helvetica-Light", 10f),
                Frame         = new CGRect(0, View.Frame.Height - 30, View.Frame.Width, 20)
            };

            View.AddSubviews(header, principalData, _activityType, _description, _startDate, _endDate, _timerView,
                             notifyClient, copyRight);
        }