Ejemplo n.º 1
0
        private void CalculateTotalHour(DiscountViewModel DVM, int CommunityCenter, DateTime fromDate, DateTime toDate)
        {
            List <string> userNum;

            using (var db = new ApplicationDbContext())
            {
                userNum = (from u in db.UserInfos
                           where u.CommunityCenterId == CommunityCenter
                           select u.EnrollNumber).ToList();

                var logs = db.LogDataInfos
                           .Where(c => c.LogDate >= fromDate && c.LogDate <= toDate)
                           .Include("UserInfo").Include("UserInfo.CommunityCenter")
                           .Include("UserInfo.Department").ToList();

                var results = from l in logs
                              group l by new { l.EnrollNum } into g
                where userNum.Contains(g.Key.EnrollNum)
                select new { Num = g.Key.EnrollNum, Times = g.OrderBy(c => c.LogDate).ThenBy(c => c.LogTime).ToList() };

                int totalHour = 0;
                int totalMin  = 0;

                foreach (var r in results)
                {
                    totalHour = 0;
                    foreach (var t in r.Times)
                    {
                        if (t.LogOutTime != TimeSpan.Zero)
                        {
                            TimeSpan dif = t.LogOutTime.Subtract(t.LogTime);
                            totalHour += dif.Hours;
                            totalMin  += dif.Minutes;
                        }
                    }
                    totalHour += totalMin / 60;
                    totalMin   = totalMin % 60;

                    var hd = DVM.Details.Where(c => c.EnrollNum == r.Num).FirstOrDefault();
                    if (hd == null)
                    {
                        DiscountDetailViewModel newDetail = new DiscountDetailViewModel();
                        newDetail.Name           = logs.FirstOrDefault(c => c.EnrollNum == r.Num).UserInfo.FullName;
                        newDetail.EnrollNum      = r.Num;
                        newDetail.CommunityName  = logs.FirstOrDefault(c => c.EnrollNum == r.Num).UserInfo.CommunityCenter.Name;
                        newDetail.DepartmentName = logs.FirstOrDefault(c => c.EnrollNum == r.Num).UserInfo.Department.Name;
                        newDetail.TotalHours     = totalHour;
                        newDetail.TotalMins      = totalMin;
                        newDetail.TotalTime      = String.Format("{0}:{1}", totalHour, totalMin);
                        DVM.Details.Add(newDetail);
                    }
                    else
                    {
                        hd.TotalHours = totalHour;
                        hd.TotalMins  = totalMin;
                        hd.TotalTime  = String.Format("{0}:{1}", totalHour, totalMin);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void CalcSumDailyVacation(DiscountViewModel DVM, int CommunityCenter, DateTime fromDate, DateTime toDate)
 {
     using (var db = new ApplicationDbContext())
     {
         var dailys = (from d in db.DailyVacations
                       where d.UserInfo.CommunityCenterId == CommunityCenter &&
                       d.FromDate >= fromDate && d.FromDate <= toDate
                       group d by new
         {
             Num = d.UserInfo.EnrollNumber,
             Name = d.UserInfo.FullName,
             CName = d.UserInfo.CommunityCenter.Name,
             DName = d.UserInfo.Department.Name
         } into g
                       select new { Num = g.Key.Num, Name = g.Key.Name, Center = g.Key.CName, Department = g.Key.DName, DaySum = g.Sum(c => c.Duration) }).ToList();
         foreach (var dr in dailys)
         {
             var detail = DVM.Details.Where(d => d.EnrollNum == dr.Num.ToString()).FirstOrDefault();
             if (detail == null)
             {
                 DiscountDetailViewModel newDetail = new DiscountDetailViewModel();
                 newDetail.Name               = dr.Name;
                 newDetail.EnrollNum          = dr.Num.ToString();
                 newDetail.CommunityName      = dr.Center;
                 newDetail.DepartmentName     = dr.Department;
                 newDetail.TotalDailyVacation = dr.DaySum;
                 DVM.Details.Add(newDetail);
             }
             else
             {
                 detail.TotalDailyVacation = dr.DaySum;
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void CalcSumHourVacation(DiscountViewModel DVM, int CommunityCenter, DateTime fromDate, DateTime toDate)
 {
     // var hours = new[] { new { Num = default(string), Name = default(string), Center = default(string), Department = default(string), HourSum = default(double) } }.Skip(1).ToList();
     using (var db = new ApplicationDbContext())
     {
         var hours = (from h in db.HourlyVacations
                      where h.UserInfo.CommunityCenter.Id == CommunityCenter &&
                      h.VacationDate >= fromDate &&
                      h.VacationDate <= toDate
                      group h by new
         {
             Num = h.UserInfo.EnrollNumber,
             Name = h.UserInfo.FullName,
             CName = h.UserInfo.CommunityCenter.Name,
             DName = h.UserInfo.Department.Name
         } into g
                      select new { Num = g.Key.Num, Name = g.Key.Name, Center = g.Key.CName, Department = g.Key.DName, HourSum = g.Sum(c => c.Duration.Hours * 60 + c.Duration.Minutes) / 60.0 }).ToList();
         foreach (var hour in hours)
         {
             var hd = DVM.Details.Where(d => d.EnrollNum == hour.Num).FirstOrDefault();
             if (hd == null)
             {
                 DiscountDetailViewModel newDetail = new DiscountDetailViewModel();
                 newDetail.Name            = hour.Name;
                 newDetail.EnrollNum       = hour.Num;
                 newDetail.CommunityName   = hour.Center;
                 newDetail.DepartmentName  = hour.Department;
                 newDetail.TotalHouVacatin = hour.HourSum;
                 DVM.Details.Add(newDetail);
             }
             else
             {
                 hd.TotalHouVacatin = hour.HourSum;
             }
         }
     }
 }
Ejemplo n.º 4
0
        public DiscountViewModel MapToViewModel(Discount model)
        {
            DiscountViewModel viewModel = new DiscountViewModel();

            PropertyCopier <Discount, DiscountViewModel> .Copy(model, viewModel);

            viewModel.code          = model.Code;
            viewModel.discountOne   = model.DiscountOne;
            viewModel.discountTwo   = model.DiscountTwo;
            viewModel.endDate       = model.EndDate;
            viewModel.startDate     = model.StartDate;
            viewModel.information   = model.Information;
            viewModel.storeCategory = model.StoreCategory;
            viewModel.store         = new StoreViewModel
            {
                name = model.StoreName
            };
            viewModel.Active             = model.Active;
            viewModel.Id                 = model.Id;
            viewModel._CreatedAgent      = model._CreatedAgent;
            viewModel._CreatedBy         = model._CreatedBy;
            viewModel._IsDeleted         = model._IsDeleted;
            viewModel._LastModifiedAgent = model._LastModifiedAgent;
            viewModel._LastModifiedBy    = model._LastModifiedBy;
            viewModel._LastModifiedUtc   = model._LastModifiedUtc;


            viewModel.items = new List <DiscountItemViewModel>();
            if (model.Items != null)
            {
                foreach (DiscountItem mdni in model.Items)
                {
                    DiscountItemViewModel discountItemView = new DiscountItemViewModel();
                    PropertyCopier <DiscountItem, DiscountItemViewModel> .Copy(mdni, discountItemView);

                    discountItemView.details = new List <DiscountDetailViewModel>();
                    foreach (DiscountDetail mdnd in mdni.Details)
                    {
                        DiscountDetailViewModel discountDetailViewModel = new DiscountDetailViewModel();
                        PropertyCopier <DiscountDetail, DiscountDetailViewModel> .Copy(mdnd, discountDetailViewModel);

                        discountDetailViewModel.dataDestination = new ItemViewModelRead {
                            ArticleRealizationOrder = mdnd.ArticleRealizationOrder,
                            code = mdnd.Code,
                            name = mdnd.Name,
                            Size = mdnd.Size,
                            Uom  = mdnd.Uom,
                        };
                        //ItemViewModelRead itemViewModelRead = new ItemViewModelRead
                        //{
                        //    ArticleRealizationOrder = mdnd.ArticleRealizationOrder,
                        //    code = mdnd.Code,
                        //    name = mdnd.Name,
                        //    Size = mdnd.Size,
                        //    Uom = mdnd.Uom,
                        //};
                        //discountDetailViewModel.dataDestination.Add(itemViewModelRead);

                        discountDetailViewModel.DomesticCOGS           = mdnd.DomesticCOGS;
                        discountDetailViewModel.DomesticRetail         = mdnd.DomesticRetail;
                        discountDetailViewModel.DomesticSale           = mdnd.DomesticSale;
                        discountDetailViewModel.DomesticWholesale      = mdnd.DomesticWholesale;
                        discountDetailViewModel.InternationalCOGS      = mdnd.InternationalCOGS;
                        discountDetailViewModel.InternationalRetail    = mdnd.InternationalRetail;
                        discountDetailViewModel.InternationalSale      = mdnd.InternationalSale;
                        discountDetailViewModel.InternationalWholesale = mdnd.InternationalWholesale;
                        discountDetailViewModel.Id                 = mdnd.Id;
                        discountDetailViewModel._CreatedAgent      = mdnd._CreatedAgent;
                        discountDetailViewModel._CreatedBy         = mdnd._CreatedBy;
                        discountDetailViewModel._IsDeleted         = mdnd._IsDeleted;
                        discountDetailViewModel._LastModifiedAgent = mdnd._LastModifiedAgent;
                        discountDetailViewModel._LastModifiedBy    = mdnd._LastModifiedBy;
                        discountDetailViewModel._LastModifiedUtc   = mdnd._LastModifiedUtc;
                        discountItemView.details.Add(discountDetailViewModel);
                    }
                    discountItemView.realizationOrder = mdni.RealizationOrder;
                    discountItemView.Active           = mdni.Active;
                    discountItemView.Id                 = mdni.Id;
                    discountItemView._CreatedAgent      = mdni._CreatedAgent;
                    discountItemView._IsDeleted         = mdni._IsDeleted;
                    discountItemView._LastModifiedAgent = mdni._LastModifiedAgent;
                    discountItemView._LastModifiedBy    = mdni._LastModifiedBy;
                    discountItemView._LastModifiedUtc   = mdni._LastModifiedUtc;
                    viewModel.items.Add(discountItemView);
                }
            }

            return(viewModel);
        }
Ejemplo n.º 5
0
        public BranchInfoViewTemplate(DiscountDetailContentUI parentContentUi, DiscountDetailViewModel parentViewModel)
        {
            var stackBranch = new StackLayout
            {
                Padding         = new Thickness(20, 10),
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            #region Location

            var gridLocation = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Star
                    }
                }
            };

            var txtDistanceValue = new Label
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                Style             = LabelStyles.DetailDistanceStyle.FromResources <Style>()
            };
            txtDistanceValue.SetBinding(Label.TextProperty, "DistanceString");

            gridLocation.Children.Add(txtDistanceValue, 0, 0);

            var distanceLabel = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Margin          = new Thickness(0, 0, 10, 0),
                TranslationY    = 2,
                Spacing         = 0,
                Children        =
                {
                    new Image
                    {
                        Source = parentContentUi.ImgDistance
                    },
                    new Label
                    {
                        Text  = parentContentUi.TxtDistanceScaleValue,
                        Style = LabelStyles.DescriptionStyle.FromResources <Style>()
                    }
                }
            };

            gridLocation.Children.Add(distanceLabel, 1, 0);

            var txtPartnerAddress = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Style           = LabelStyles.DescriptionStyle.FromResources <Style>()
            };
            txtPartnerAddress.SetBinding(Label.TextProperty, "Address");

            var txtShowOnMap = new Label
            {
                Text          = parentContentUi.TxtShowOnMap,
                Style         = LabelStyles.LinkStyle.FromResources <Style>(),
                LineBreakMode = LineBreakMode.TailTruncation
            };

            var locationLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Spacing         = 0,
                Children        =
                {
                    txtPartnerAddress,
                    txtShowOnMap
                }
            };

            var tapShowOnMapp = new TapGestureRecognizer();
            tapShowOnMapp.SetBinding(TapGestureRecognizer.CommandParameterProperty, "DocumentId");
            tapShowOnMapp.Tapped += parentViewModel.ShowOnMap_Click;

            locationLayout.GestureRecognizers.Add(tapShowOnMapp);

            gridLocation.Children.Add(locationLayout, 2, 0);

            stackBranch.Children.Add(gridLocation);

            #endregion

            #region Phone list

            var stackPhoneView = new StackLayout
            {
                Padding = new Thickness(0, 4)
            };

            #region phone1

            var tapPhone1 = new TapGestureRecognizer();
            tapPhone1.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Phone1");
            tapPhone1.Tapped += parentViewModel.BtnCall_Click;

            var phone1 = CreateCallButton("Phone1", "PhoneOperatorIcon1");
            phone1.SetBinding(VisualElement.IsVisibleProperty, "IsPhone1Exists");
            phone1.GestureRecognizers.Add(tapPhone1);

            stackPhoneView.Children.Add(phone1);

            #endregion

            #region phone2

            var tapPhone2 = new TapGestureRecognizer();
            tapPhone2.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Phone2");
            tapPhone2.Tapped += parentViewModel.BtnCall_Click;

            var phone2 = CreateCallButton("Phone2", "PhoneOperatorIcon2");
            phone2.SetBinding(VisualElement.IsVisibleProperty, "IsPhone2Exists");
            phone2.GestureRecognizers.Add(tapPhone2);

            stackPhoneView.Children.Add(phone2);

            #endregion

            stackBranch.Children.Add(stackPhoneView);

            #endregion

            View = stackBranch;
        }
Ejemplo n.º 6
0
        private void CalculateDiscountDay(DiscountViewModel DVM, int CommunityCenter, DateTime fromDate, DateTime toDate)
        {
            int    totalPrevVacation = (int)fromDate.Month;
            double daydiscount       = 0;
            double restHour          = 0.0;

            using (var db = new ApplicationDbContext())
            {
                List <DailyVacation> takenVacation = db.DailyVacations.Where(c => c.IsActive && c.VacationType.IsDiscount && c.VacationType.IsAdministrative && c.FromDate < fromDate)
                                                     .Include("UserInfo")
                                                     .ToList();

                var users = (from u in db.UserInfos
                             where u.CommunityCenterId == CommunityCenter &&
                             u.EnrollNumber == "258"
                             select u).Include("CommunityCenter")
                            .Include("Department")
                            .ToList();

                var dailys = (from d in db.DailyVacations
                              where d.UserInfo.CommunityCenterId == CommunityCenter &&
                              d.IsActive &&
                              d.FromDate >= fromDate && d.FromDate <= toDate &&
                              d.VacationType.IsDiscount &&
                              d.VacationType.IsAdministrative
                              group d by new
                {
                    Num = d.UserInfo.EnrollNumber,
                    Name = d.UserInfo.FullName,
                    CName = d.UserInfo.CommunityCenter.Name,
                    DName = d.UserInfo.Department.Name
                }
                              into g
                              select new
                {
                    Num = g.Key.Num,
                    Name = g.Key.Name,
                    Center = g.Key.CName,
                    Department = g.Key.DName,
                    DaySum = g.Sum(c => c.Duration)
                }).ToList();


                var hours = (from h in db.HourlyVacations
                             where h.UserInfo.CommunityCenter.Id == CommunityCenter &&
                             h.VacationDate >= fromDate &&
                             h.VacationDate <= toDate &&
                             h.IsActive
                             group h by new
                {
                    Num = h.UserInfo.EnrollNumber,
                    Name = h.UserInfo.FullName,
                    CName = h.UserInfo.CommunityCenter.Name,
                    DName = h.UserInfo.Department.Name
                }
                             into g
                             select new
                {
                    Num = g.Key.Num,
                    Name = g.Key.Name,
                    Center = g.Key.CName,
                    Department = g.Key.DName,
                    HourSum = g.Sum(c => c.Duration.Hours * 60 + c.Duration.Minutes) / 60.0
                }).ToList();



                foreach (var u in users)
                {
                    //*************** حساب الحسم من الاجازات اليومية
                    //حساب مجموعة الاجازات في الأشهر السابقة
                    var sumtakenVacation = takenVacation?.Where(c => c.UserInfo.EnrollNumber == u.EnrollNumber)
                                           ?.Sum(c => (int?)c.Duration > 1 ? 1 : (int?)c.Duration) ?? 0;

                    //حساب مجموع الاجازات الساعية في هذا الشهر
                    var sumHourvacation = hours.Where(c => c.Num == u.EnrollNumber).FirstOrDefault()?.HourSum ?? 0;

                    var daySum = dailys.FirstOrDefault(c => c.Num == u.EnrollNumber)?.DaySum ?? 0;
                    //الاجازات الكلية =مجموع الاجازات في هذا الشهر +ناتج قسمة ا
                    var totalVacatin = daySum + (int)(sumHourvacation / 8);
                    restHour = (int)sumHourvacation % 8;

                    #region حساب الساعات السابقة المتراكمة

                    var tt = 0.0;
                    for (int i = 1; i < fromDate.Month; i++)
                    {
                        double?totalHour;

                        var i1 = i;
                        totalHour = db.HourlyVacations
                                    .Where(c => c.IsActive && c.VacationDate.Month == i1 &&
                                           c.UserInfo.EnrollNumber == u.EnrollNumber)
                                        ?
                                    .Sum(c => (double?)c.Duration.Hours + (double)(c.Duration.Minutes) / 60.0) ??
                                    0;
                        tt += totalHour.Value % 8;
                    }

                    if (fromDate.Day > 1)
                    {
                        var da        = new DateTime(fromDate.Year, fromDate.Month, 1);
                        var totalHour = db.HourlyVacations
                                        .Where(c => c.IsActive &&
                                               c.VacationDate >= da &&
                                               c.VacationDate < new DateTime(2019, 4, 17) &&
                                               c.UserInfo.EnrollNumber == u.EnrollNumber)
                                        ?.Sum(c => (double?)c.Duration.Hours +
                                              (double)(c.Duration.Minutes / 60.0)) ?? 0;
                        tt += totalHour % 8;
                    }

                    #endregion

                    totalVacatin     += (int)(tt % 8 + restHour) / 8;
                    sumtakenVacation += (int)tt / 8;
                    var vacationWithoutSalary = db.DailyVacations.Where(
                        c => c.IsActive && c.VacationType.IsDiscount && c.VacationType.IsAdministrative == false &&
                        c.FromDate >= fromDate && c.FromDate <= toDate && c.UserInfo.EnrollNumber == u.EnrollNumber).ToList();
                    int sumVacWithoutSal = 0;
                    if (vacationWithoutSalary.Count != 0)
                    {
                        sumVacWithoutSal = vacationWithoutSalary.Sum(c => c.Duration);
                    }
                    //DayDiscount > 0 يوجد حسم
                    //DayDiscount =0 لايوجد حسم
                    //DayDiscount <0 الموظف لديه اجازات لم تؤخذ بعد
                    if (sumtakenVacation < totalPrevVacation)
                    {
                        daydiscount = totalVacatin - ((totalPrevVacation - sumtakenVacation) + 1);
                    }
                    else
                    {
                        daydiscount = totalVacatin - (+1);
                    }
                    daydiscount += sumVacWithoutSal;

                    var hd = DVM.Details.Where(c => c.EnrollNum == u.EnrollNumber).FirstOrDefault();
                    if (hd == null)
                    {
                        DiscountDetailViewModel newDetail = new DiscountDetailViewModel();
                        newDetail.Name           = u.FullName;
                        newDetail.EnrollNum      = u.EnrollNumber;
                        newDetail.CommunityName  = u.CommunityCenter.Name;
                        newDetail.DepartmentName = u.Department.Name;
                        var DelayHour = Math.Abs(newDetail.DelayHour - sumHourvacation);
                        newDetail.DiscountDay = Math.Floor(daydiscount + (DelayHour / 8));
                        DVM.Details.Add(newDetail);
                    }
                    else
                    {
                        var DelayHour = Math.Abs(hd.DelayHour - sumHourvacation);
                        hd.DiscountDay = Math.Floor(daydiscount + (DelayHour / 8));
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void CalculateTotalDelay(DiscountViewModel DVM, int CommunityCenter, DateTime fromDate, DateTime toDate)
        {
            using (var db = new ApplicationDbContext())
            {
                List <string> userNum = (from u in db.UserInfos
                                         where u.CommunityCenterId == CommunityCenter
                                         select u.EnrollNumber).ToList();
                List <LogDataInfo> logs = db.LogDataInfos
                                          .Where(c => c.LogDate >= fromDate && c.LogDate <= toDate)
                                          .Include("UserInfo").Include("UserInfo.CommunityCenter")
                                          .Include("UserInfo.Department").ToList();
                List <CommunityCenter> communityCenters = db.CommunityCenters.ToList();
                var delayresults =
                    from l in logs
                    group l by new
                {
                    l.EnrollNum,
                    l.UserInfo.FullName,
                    CenterN = l.UserInfo.CommunityCenter.Name,
                    Dept    = l.UserInfo.Department.Name,
                    l.LogDate
                } into g
                where userNum.Contains(g.Key.EnrollNum)
                select new
                {
                    Num        = g.Key.EnrollNum,
                    Name       = g.Key.FullName,
                    Center     = g.Key.CenterN,
                    Department = g.Key.Dept,
                    Date       = g.Key.LogDate,
                    Times      = g.OrderBy(c => c.LogTime).ToList()
                };


                foreach (var dr in delayresults)
                {
                    var maxTimeout   = dr.Times.Max(c => c.LogOutTime);
                    var minTimeIn    = dr.Times.Min(c => c.LogTime);
                    var maxCenterLog = (communityCenters.FirstOrDefault(d => d.Id == dr.Times.FirstOrDefault(c => c.LogOutTime == maxTimeout)?.CommunityCenterId)?.BeginingCOut).Value;
                    var minCenterLog = (communityCenters.FirstOrDefault(d => d.Id == dr.Times.FirstOrDefault(c => c.LogTime == minTimeIn)?.CommunityCenterId)?.EndingCIn).Value;

                    TimeSpan diffIn  = TimeSpan.Zero;
                    TimeSpan diffOut = TimeSpan.Zero;
                    if (maxCenterLog != null && maxTimeout != TimeSpan.Zero && maxTimeout < maxCenterLog)
                    {
                        diffOut = maxCenterLog.Subtract(maxTimeout);
                    }

                    if (minTimeIn != TimeSpan.Zero && minTimeIn > minCenterLog)
                    {
                        diffIn = minTimeIn.Subtract(minCenterLog);
                    }
                    var hd = DVM.Details.FirstOrDefault(c => c.EnrollNum == dr.Num);
                    if (hd == null)
                    {
                        DiscountDetailViewModel newDetail = new DiscountDetailViewModel();
                        newDetail.Name           = dr.Name;
                        newDetail.EnrollNum      = dr.Num;
                        newDetail.CommunityName  = dr.Center;
                        newDetail.DepartmentName = dr.Department;
                        newDetail.DelayHour      = diffIn.Hours + diffOut.Hours;
                        newDetail.DelayMins      = diffIn.Minutes + diffOut.Minutes;
                        DVM.Details.Add(newDetail);
                    }
                    else
                    {
                        hd.DelayHour += diffIn.Hours + diffOut.Hours;
                        hd.DelayMins += diffIn.Minutes + diffOut.Hours;
                    }
                }
                foreach (var detail in DVM.Details)
                {
                    detail.DelayHour += detail.DelayMins / 60;
                    detail.DelayMins  = detail.DelayMins % 60;
                    detail.TotalDelay = $"{detail.DelayHour}: {detail.DelayMins}";
                }
            }
        }
Ejemplo n.º 8
0
            public BranchInfoViewTemplate(ListView parentListView, DiscountDetailContentUI parentContentUI, DiscountDetailViewModel parentViewModel)
            {
                IsHighlightSelection = false;

                var stackBranch = new StackLayout
                {
                    Padding         = new Thickness(18, 0),
                    VerticalOptions = LayoutOptions.FillAndExpand
                };

                #region Location
                Grid gridLocation = new Grid
                {
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        }
                    },
                    ColumnDefinitions =
                    {
                        new ColumnDefinition  {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition  {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition  {
                            Width = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };

                var txtDistanceValue = new Label
                {
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Start,
                    Style             = (Style)App.Current.Resources[LabelStyles.DetailDistanceStyle]
                };
                txtDistanceValue.SetBinding(Label.TextProperty, "Distance");

                var distanceLabel = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Spacing         = 0,
                    Children        =
                    {
                        new Image
                        {
                            Source = parentContentUI.ImgDistance
                        },
                        new Label
                        {
                            Text  = parentContentUI.TxtDistanceScaleValue,
                            Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
                        }
                    }
                };

                gridLocation.Children.Add(txtDistanceValue, 0, 0);
                gridLocation.Children.Add(distanceLabel, 1, 0);

                var txtPartnerAddress = new Label
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    Style           = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
                };
                txtPartnerAddress.SetBinding(Label.TextProperty, "Address");

                var txtShowOnMap = new LabelExtended
                {
                    Text        = parentContentUI.TxtShowOnMap,
                    Style       = (Style)App.Current.Resources[LabelStyles.LinkStyle],
                    IsUnderline = true
                };

                var locationLayout = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Spacing         = 0,
                    Children        =
                    {
                        txtPartnerAddress,
                        txtShowOnMap
                    }
                };

                var viewGesturesShowOnMap = new ViewGestures
                {
                    Content          = locationLayout,
                    DeformationValue = -5,
                };
                viewGesturesShowOnMap.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesShowOnMap.Tap            += parentViewModel.ShowOnMap_Click;
                viewGesturesShowOnMap.SetBinding(ViewGestures.TagProperty, "DocumentId");

                gridLocation.Children.Add(viewGesturesShowOnMap, 2, 0);

                stackBranch.Children.Add(gridLocation);

                #endregion

                #region Phone list
                var stackPhoneView = new StackLayout
                {
                    Padding = Device.OnPlatform(new Thickness(0, 4), new Thickness(0, 4), new Thickness(0, 4, -8, 4)),
                };

                #region phone1
                var phone1 = CreateCallButton(parentContentUI, "Phone1");
                phone1.SetBinding(BorderBox.TagProperty, "Phone1");

                var viewGesturesPhone1 = new ViewGestures
                {
                    Content          = phone1,
                    DeformationValue = -5,
                };
                viewGesturesPhone1.SetBinding(ViewGestures.IsVisibleProperty, "IsPhone1FillIn");
                viewGesturesPhone1.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesPhone1.Tap            += parentViewModel.BtnCall_Click;
                stackPhoneView.Children.Add(viewGesturesPhone1);
                #endregion

                #region phone2
                var phone2 = CreateCallButton(parentContentUI, "Phone2");
                phone2.SetBinding(BorderBox.TagProperty, "Phone2");

                var viewGesturesPhone2 = new ViewGestures
                {
                    Content          = phone2,
                    DeformationValue = -5,
                };
                viewGesturesPhone2.SetBinding(ViewGestures.IsVisibleProperty, "IsPhone2FillIn");
                viewGesturesPhone2.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesPhone2.Tap            += parentViewModel.BtnCall_Click;
                stackPhoneView.Children.Add(viewGesturesPhone2);
                #endregion

                stackBranch.Children.Add(stackPhoneView);
                #endregion

                View = stackBranch;
            }