Ejemplo n.º 1
0
 public static string SaveChartOfAccount(AccountCreateViewModel model)
 {
     if (model.Id > 0)
     {
         if (!string.IsNullOrEmpty(model.SegmentName1) && !model.SegmentEnabled1)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName1);
             if (accountValues.Any())
             {
                 return("Segment 1 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName2) && !model.SegmentEnabled2)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName2);
             if (accountValues.Any())
             {
                 return("Segment 2 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName3) && !model.SegmentEnabled3)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName3);
             if (accountValues.Any())
             {
                 return("Segment 3 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName4) && !model.SegmentEnabled4)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName4);
             if (accountValues.Any())
             {
                 return("Segment 4 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName5) && !model.SegmentEnabled5)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName5);
             if (accountValues.Any())
             {
                 return("Segment 5 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName6) && !model.SegmentEnabled6)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName6);
             if (accountValues.Any())
             {
                 return("Segment 6 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName7) && !model.SegmentEnabled7)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName7);
             if (accountValues.Any())
             {
                 return("Segment 7 can not be marked as disabled");
             }
         }
         else if (!string.IsNullOrEmpty(model.SegmentName8) && !model.SegmentEnabled8)
         {
             List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(model.Id, SessionHelper.SOBId, model.SegmentName8);
             if (accountValues.Any())
             {
                 return("Segment 8 can not be marked as disabled");
             }
         }
         return(service.Update(getEntityByModel(model)));
     }
     else
     {
         return(service.Insert(getEntityByModel(model)));
     }
 }
Ejemplo n.º 2
0
        public static List <Segment> GetSegmentListForCodeCombination(string sobId, bool fetchSaved = false)
        {
            List <Segment> segmentList = new List <Segment>();
            Account        account     = AccountHelper.GetAccountBySOBId(sobId);

            #region Filling Segments

            if (account != null)
            {
                if (account.SegmentEnabled1 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName1, 1, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 1,
                            SegmentName      = account.SegmentName1,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName1, 1, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled2 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName2, 2, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 2,
                            SegmentName      = account.SegmentName2,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName2, 2, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled3 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName3, 3, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 3,
                            SegmentName      = account.SegmentName3,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName3, 3, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled4 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName4, 4, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 4,
                            SegmentName      = account.SegmentName4,
                            SegmentValueList = accountValues
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled5 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName5, 5, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 5,
                            SegmentName      = account.SegmentName5,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName5, 5, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled6 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName6, 6, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 6,
                            SegmentName      = account.SegmentName6,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName6, 6, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled7 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName7, 7, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 7,
                            SegmentName      = account.SegmentName7,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName7, 7, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }

                if (account.SegmentEnabled8 == true)
                {
                    List <AccountValueViewModel> accountValues = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName8, 8, fetchSaved);
                    if (accountValues.Any())
                    {
                        segmentList.Add(new Segment
                        {
                            SegmentCount     = 8,
                            SegmentName      = account.SegmentName8,
                            SegmentValueList = AccountValueHelper.GetAccountValues(account.Id, account.SOBId, account.SegmentName8, 8, fetchSaved)
                                               .Select(x => new SelectListItem
                            {
                                Value = x.Value,
                                Text  = x.ValueName
                            }).ToList()
                        });
                    }
                }
            }

            #endregion

            return(segmentList);
        }