public void Mapping(Profile profile)
 {
     profile.CreateMap <Order, GetOrdersForContractorDto>()
     .ForMember(d => d.Client, opt => opt.MapFrom(s => s.Client.User.FirstName + " " + s.Client.User.LastName))
     .ForMember(d => d.Category, opt => opt.MapFrom(s => s.Category.DisplayName))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
 public void Mapping(Profile profile)
 {
     profile.CreateMap <User, GetCurrentContractorUserDto>()
     .ForMember(d => d.Gender, opt => opt.MapFrom(s => new CurrentContracorUserGenderDto
     {
         GenderGuid = s.GenderCode.CodeGuid,
         Name       = s.GenderCode.DisplayName
     }))
     .ForMember(d => d.City, opt => opt.MapFrom(s => new CurrentContracorUserCityDto
     {
         CityGuid = s.Contractor.SingleOrDefault().City.CityGuid,
         Name     = s.Contractor.SingleOrDefault().City.Name
     }))
     .ForMember(d => d.Latitude, opt => opt.MapFrom(s => s.Contractor.SingleOrDefault().Latitude))
     .ForMember(d => d.Longitude, opt => opt.MapFrom(s => s.Contractor.SingleOrDefault().Longitude))
     .ForMember(d => d.Credit, opt => opt.MapFrom(s => s.Contractor.SingleOrDefault().Credit))
     .ForMember(d => d.AverageRate, opt => opt.MapFrom(s => s.Contractor.SingleOrDefault().AverageRate))
     .ForMember(d => d.ProfileDocument, opt => opt.MapFrom(s => s.ProfileDocument.Path))
     .ForMember(d => d.Business, opt => opt.MapFrom(s => new CurrentContracorUserBusinessDto
     {
         BusinessGuid = s.Contractor.SingleOrDefault().BusinessTypeCode.CodeGuid,
         Name         = s.Contractor.SingleOrDefault().BusinessTypeCode.DisplayName
     }))
     .ForMember(d => d.RegisteredDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.RegisteredDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 3
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <Post, GetSliderPostsDto>()
     .ForMember(d => d.UserFullName, opt => opt.MapFrom(s => s.User.FirstName + " " + s.User.LastName))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")))
     .ForMember(d => d.Slug, opt => opt.MapFrom(s => s.Title.Trim().ToLowerInvariant().Replace(" ", "-")))
     .ForMember(d => d.Document, opt => opt.MapFrom(s => new FilepondDto
     {
         Source  = s.Document.Path,
         Options = new FilepondOptions
         {
             Type  = "local",
             Files = new FilepondFile
             {
                 Name = s.Document.Name,
                 Size = s.Document.Size.ToString(),
                 Type = s.Document.TypeCode.Name
             },
             Metadata = new FilepondMetadata
             {
                 Poster = s.Document.Path
             }
         }
     }));
 }
Ejemplo n.º 4
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <OrderRequest, GetChatRoomsDto>()
     .ForMember(d => d.Client, opt => opt.MapFrom(s => s.Order.Client.User.FirstName + " " + s.Order.Client.User.LastName))
     .ForMember(d => d.RecentMessage, opt => opt.MapFrom(s => s.ChatMessage.OrderByDescending(x => x.ModifiedDate).FirstOrDefault().Text))
     .ForMember(d => d.IsAllow, opt => opt.MapFrom(s => s.IsAllow))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 5
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <User, GetAllAdminsDto>()
     .ForMember(d => d.Gender, opt => opt.MapFrom(s => s.GenderCode.DisplayName))
     .ForMember(d => d.ProfileImage, opt => opt.MapFrom(s => s.ProfileDocument.Path))
     .ForMember(d => d.RegisteredDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.RegisteredDate, "yyyy/MM/dd HH:mm")))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 6
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <Order, GetClientOrdersDto>()
     .ForMember(d => d.Category, opt => opt.MapFrom(s => s.Category.DisplayName))
     //.ForMember(d => d.Contractor, opt => opt.MapFrom(s => s.Contractor.User.FirstName + " " + s.Contractor.User.LastName))
     .ForMember(d => d.RequestsCount, opt => opt.MapFrom(s => s.OrderRequest.Count))
     .ForMember(d => d.State, opt => opt.MapFrom(s => s.StateCode.DisplayName))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
 public void Mapping(Profile profile)
 {
     profile.CreateMap <OrderRequest, GetOrderRequestsForAdminDto>()
     .ForMember(d => d.IsAllowed, opt => opt.MapFrom(s => s.IsAllow))
     .ForMember(d => d.IsAccepted, opt => opt.MapFrom(s => s.IsAccept))
     .ForMember(d => d.IsAccessible, opt => opt.MapFrom(s => (s.Order.StateCodeId == 9 && s.IsAllow) || s.IsAccept))
     .ForMember(d => d.Contractor, opt => opt.MapFrom(s => s.Contractor.User.FirstName + " " + s.Contractor.User.LastName))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 8
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <User, GetCurrentAdminUserDto>()
     .ForMember(d => d.Gender, opt => opt.MapFrom(s => new CurrentAdminUserGenderDto
     {
         GenderGuid = s.GenderCode.CodeGuid,
         Name       = s.GenderCode.DisplayName
     }))
     .ForMember(d => d.RegisteredDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.RegisteredDate, "yyyy/MM/dd HH:mm")));
 }
 public void Mapping(Profile profile)
 {
     profile.CreateMap <User, GetCurrentClientUserDto>()
     .ForMember(d => d.Gender, opt => opt.MapFrom(s => s.GenderCode.DisplayName))
     .ForMember(d => d.City, opt => opt.MapFrom(s => new CurrentClientUserCityDto
     {
         CityGuid = s.Client.SingleOrDefault().City.CityGuid,
         Name     = s.Client.SingleOrDefault().City.Name
     }))
     .ForMember(d => d.RegisteredDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.RegisteredDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 10
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <User, GetAllContractorsDto>()
     .ForMember(d => d.Gender, opt => opt.MapFrom(s => s.GenderCode.DisplayName))
     .ForMember(d => d.ProfileImage, opt => opt.MapFrom(s => s.ProfileDocument.Path))
     .ForMember(d => d.City, opt => opt.MapFrom(s => s.Contractor.Select(x => x.City.Name).FirstOrDefault()))
     .ForMember(d => d.Business, opt => opt.MapFrom(s => s.Contractor.Select(x => x.BusinessTypeCode.Name).FirstOrDefault()))
     .ForMember(d => d.Latitude, opt => opt.MapFrom(s => s.Contractor.Select(x => x.Latitude).FirstOrDefault()))
     .ForMember(d => d.Longitude, opt => opt.MapFrom(s => s.Contractor.Select(x => x.Longitude).FirstOrDefault()))
     .ForMember(d => d.Credit, opt => opt.MapFrom(s => s.Contractor.Select(x => x.Credit).FirstOrDefault()))
     .ForMember(d => d.AverageRate, opt => opt.MapFrom(s => s.Contractor.Select(x => x.AverageRate).FirstOrDefault()))
     .ForMember(d => d.RegisteredDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.RegisteredDate, "yyyy/MM/dd HH:mm")))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 11
0
        public IActionResult Index()
        {
            var accounts = context.Account
                           .Where(x => !x.IsDelete)
                           .OrderByDescending(x => x.ModifiedDate)
                           .Select(x => new AccountViewModel
            {
                AccountGuid   = x.AccountGuid,
                UserFullName  = x.User.FirstName + " " + x.User.LastName,
                BankName      = string.IsNullOrEmpty(x.BankName) ? Messages.NotSet : x.BankName,
                AccountName   = string.IsNullOrEmpty(x.AccountName) ? Messages.NotSet : x.AccountName,
                AccountNumber = x.AccountNumber,
                CardNumber    = string.IsNullOrEmpty(x.CardNumber) ? Messages.NotSet : x.CardNumber,
                Credit        = x.Credit,
                ModifiedDate  = PersianDateExtensionMethods.ToPeString(x.ModifiedDate, "yyyy/MM/dd HH:mm")
            }).ToList();

            return(View(accounts));
        }
Ejemplo n.º 12
0
        public async Task SendMessageAsync(Guid orderRequestGuid, string text)
        {
            User currentUser = await _currentUser.GetInfoAsync();

            OrderRequest orderRequest = await _chatRoom.GetOrderRequestAsync(orderRequestGuid);

            if (await _chatRoom.IsOrderRequestAccessibleAsync(orderRequest))
            {
                ChatMessage chatMessage = await _chatRoom.CreateMessageAsync(orderRequest.OrderRequestId, text, currentUser.UserId);

                string clientName = chatMessage.User.FirstName + " " + chatMessage.User.LastName;
                string sentAt     = PersianDateExtensionMethods.ToPeString(chatMessage.SentAt, "yyyy/MM/dd HH:mm");

                await Clients.Group(orderRequestGuid.ToString())
                .SendAsync("ReceiveMessage", clientName, chatMessage.Text, sentAt, _currentUser.Role);
            }
            else
            {
                throw new NotSupportedException("Order Is Closed");
            }
        }
Ejemplo n.º 13
0
        public IActionResult NotPassedStateTransactions()
        {
            var transactions = context.Transaction
                               .Where(x => !x.IsDelete && x.StateCodeGuid == Codes.NotPassedState)
                               .OrderByDescending(x => x.ReceiptDate)
                               .Select(x => new TransactionViewModel
            {
                TransactionGuid    = x.TransactionGuid,
                AccountNumber      = string.IsNullOrEmpty(x.Account.AccountNumber) ? Messages.NotSet : x.Account.AccountNumber,
                Type               = x.TypeCode.DisplayValue,
                State              = x.StateCode.DisplayValue,
                Cost               = x.Cost,
                AccountSide        = x.AccountSide,
                Description        = string.IsNullOrEmpty(x.Description) ? Messages.NotSet : x.Description,
                IsCheckTransaction = x.IsCheckTransaction,
                ReceiptDate        = PersianDateExtensionMethods.ToPeString(x.ReceiptDate, "yyyy/MM/dd"),
                ModifiedDate       = PersianDateExtensionMethods.ToPeString(x.ModifiedDate, "yyyy/MM/dd HH:mm")
            }).ToList();

            return(View(transactions));
        }
Ejemplo n.º 14
0
        public IActionResult ShowCheckInfo(Guid transactionGuid)
        {
            if (transactionGuid == null)
            {
                return(BadRequest());
            }

            var checkTransaction = context.CheckTransaction
                                   .Where(x => x.TransactionGuid == transactionGuid)
                                   .SingleOrDefault();

            if (checkTransaction == null)
            {
                return(NotFound());
            }

            CheckTransitionViewModel model = new CheckTransitionViewModel()
            {
                Serial    = string.IsNullOrEmpty(checkTransaction.Serial) ? Messages.NotSet : checkTransaction.Serial,
                IssueDate = PersianDateExtensionMethods.ToPeString(checkTransaction.IssueDate, "yyyy/MM/dd")
            };

            return(PartialView(model));
        }
Ejemplo n.º 15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = PersianDateExtensionMethods.GetPersianCulture();
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <IdentityUser>()
            .AddDefaultUI(UIFramework.Bootstrap4)
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Ejemplo n.º 16
0
        public IActionResult CreateAccountTransaction(CreateAccountTransactionViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.AccountGuid = Constants.DefaultAccountGuid;
                long cost = Convert.ToInt64(model.Cost);

                Transaction transaction = new Transaction
                {
                    AccountGuid   = model.AccountGuid,
                    TypeCodeGuid  = model.TypeGuid,
                    StateCodeGuid = model.StateGuid,
                    Title         = model.Title,
                    Cost          = cost,
                    AccountSide   = model.AccountSide,
                    Description   = model.Description,
                    ReceiptDate   = PersianDateExtensionMethods.ToGeorgianDateTime(model.ReceiptDate)
                };

                if (model.AccountGuid.HasValue)
                {
                    if (model.StateGuid == Codes.PassedState)
                    {
                        var account = context.Account
                                      .Where(x => x.AccountGuid == model.AccountGuid)
                                      .SingleOrDefault();

                        if (account == null)
                        {
                            TempData["ToasterState"]   = ToasterState.Error;
                            TempData["ToasterType"]    = ToasterType.Message;
                            TempData["ToasterMessage"] = Messages.CreateTransactionFailedAccountNotValid;

                            return(RedirectToAction("Index"));
                        }

                        account.Credit       = model.TypeGuid == Codes.CreditorType ? account.Credit + cost : account.Credit - cost;
                        account.ModifiedDate = DateTime.Now;

                        var transactionBefore = context.Transaction
                                                .Where(x => !x.IsDelete && x.ReceiptDate < PersianDateExtensionMethods.ToGeorgianDateTime(model.ReceiptDate))
                                                .OrderByDescending(x => x.ReceiptDate)
                                                .FirstOrDefault();

                        if (transactionBefore == null)
                        {
                            transaction.Credit = model.TypeGuid == Codes.CreditorType ? transaction.Credit + cost : transaction.Credit - cost;
                        }
                        else
                        {
                            transaction.Credit = model.TypeGuid == Codes.CreditorType ? transactionBefore.Credit + cost : transactionBefore.Credit - cost;
                        }

                        var transactionsAfter = context.Transaction
                                                .Where(x => !x.IsDelete && x.ReceiptDate > PersianDateExtensionMethods.ToGeorgianDateTime(model.ReceiptDate))
                                                .OrderBy(x => x.ReceiptDate)
                                                .ToList();

                        if (transactionsAfter.Count > 0)
                        {
                            transactionsAfter[0].Credit = transactionsAfter[0].StateCodeGuid == Codes.PassedState ?
                                                          (transactionsAfter[0].TypeCodeGuid == Codes.CreditorType ? transaction.Credit + transactionsAfter[0].Cost : transaction.Credit - transactionsAfter[0].Cost) :
                                                          (transactionsAfter[0].Credit = transaction.Credit);

                            for (int i = 1; i < transactionsAfter.Count; i++)
                            {
                                transactionsAfter[i].Credit = transactionsAfter[i].StateCodeGuid == Codes.PassedState ?
                                                              (transactionsAfter[i].TypeCodeGuid == Codes.CreditorType ? transactionsAfter[i - 1].Credit + transactionsAfter[i].Cost : transactionsAfter[i - 1].Credit - transactionsAfter[i].Cost) :
                                                              (transactionsAfter[i].Credit = transactionsAfter[i - 1].Credit);
                            }
                        }
                    }
                    else
                    {
                        var transactionBefore = context.Transaction
                                                .Where(x => !x.IsDelete && x.ReceiptDate < PersianDateExtensionMethods.ToGeorgianDateTime(model.ReceiptDate))
                                                .OrderByDescending(x => x.ReceiptDate)
                                                .FirstOrDefault();

                        transaction.Credit = transactionBefore == null ? 0 : transactionBefore.Credit;
                    }
                }

                context.Transaction.Add(transaction);

                if (Convert.ToBoolean(context.SaveChanges() > 0))
                {
                    TempData["ToasterState"]   = ToasterState.Success;
                    TempData["ToasterType"]    = ToasterType.Message;
                    TempData["ToasterMessage"] = Messages.CreateTransactionSuccessful;
                }
                else
                {
                    TempData["ToasterState"]   = ToasterState.Error;
                    TempData["ToasterType"]    = ToasterType.Message;
                    TempData["ToasterMessage"] = Messages.CreateTransactionFailed;
                }

                return(RedirectToAction("Index"));
            }

            return(BadRequest());
        }
Ejemplo n.º 17
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <User, UserDto>()
     .ForMember(d => d.UserCreateDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.RegisteredDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 18
0
        public IActionResult EditCheckTransaction(EditCheckTransactionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var checkTransaction = context.CheckTransaction
                                       .Where(x => x.TransactionGuid == model.TransactionGuid)
                                       .SingleOrDefault();

                if (checkTransaction == null)
                {
                    return(NotFound());
                }

                var transaction = context.Transaction
                                  .Where(x => x.TransactionGuid == model.TransactionGuid)
                                  .SingleOrDefault();

                var account = context.Account
                              .Where(x => x.AccountGuid == transaction.AccountGuid)
                              .SingleOrDefault();

                if (transaction.AccountGuid.HasValue && transaction.StateCodeGuid == Codes.PassedState)
                {
                    account.Credit       = transaction.TypeCodeGuid == Codes.CreditorType ? account.Credit - transaction.Cost : account.Credit + transaction.Cost;
                    account.ModifiedDate = DateTime.Now;
                }

                model.AccountGuid = Constants.DefaultAccountGuid;
                long     cost = Convert.ToInt64(model.Cost);
                DateTime transactionOldReceiptDate = transaction.ReceiptDate;

                if (model.AccountGuid.HasValue && model.StateGuid == Codes.PassedState)
                {
                    account.Credit       = model.TypeGuid == Codes.CreditorType ? account.Credit + cost : account.Credit - cost;
                    account.ModifiedDate = DateTime.Now;
                }

                transaction.AccountGuid    = model.AccountGuid;
                transaction.TypeCodeGuid   = model.TypeGuid;
                transaction.StateCodeGuid  = model.StateGuid;
                transaction.Title          = model.Title;
                transaction.Cost           = cost;
                transaction.AccountSide    = model.AccountSide;
                checkTransaction.Serial    = model.Serial;
                transaction.Description    = model.Description;
                checkTransaction.IssueDate = PersianDateExtensionMethods.ToGeorgianDateTime(model.IssueDate);
                transaction.ReceiptDate    = PersianDateExtensionMethods.ToGeorgianDateTime(model.ReceiptDate);
                transaction.ModifiedDate   = DateTime.Now;

                DateTime dateToUpdateFrom = transactionOldReceiptDate < transaction.ReceiptDate ? transactionOldReceiptDate : transaction.ReceiptDate;

                var transactionBefore = context.Transaction
                                        .Where(x => !x.IsDelete && x.ReceiptDate < dateToUpdateFrom)
                                        .OrderByDescending(x => x.ReceiptDate)
                                        .FirstOrDefault();

                long transactionBeforeCredit = transactionBefore == null ? 0 : transactionBefore.Credit;

                var transactionsAfter = context.Transaction
                                        .Where(x => !x.IsDelete && x.ReceiptDate > dateToUpdateFrom && x.TransactionGuid != transaction.TransactionGuid)
                                        .OrderBy(x => x.ReceiptDate)
                                        .ToList();

                transactionsAfter.Add(transaction);
                transactionsAfter = transactionsAfter.OrderBy(x => x.ReceiptDate)
                                    .ToList();

                if (transactionsAfter.Count > 0)
                {
                    transactionsAfter[0].Credit = transactionsAfter[0].StateCodeGuid == Codes.PassedState ?
                                                  (transactionsAfter[0].TypeCodeGuid == Codes.CreditorType ? transactionBeforeCredit + transactionsAfter[0].Cost : transactionBeforeCredit - transactionsAfter[0].Cost) :
                                                  (transactionsAfter[0].Credit = transactionBeforeCredit);

                    for (int i = 1; i < transactionsAfter.Count; i++)
                    {
                        transactionsAfter[i].Credit = transactionsAfter[i].StateCodeGuid == Codes.PassedState ?
                                                      (transactionsAfter[i].TypeCodeGuid == Codes.CreditorType ? transactionsAfter[i - 1].Credit + transactionsAfter[i].Cost : transactionsAfter[i - 1].Credit - transactionsAfter[i].Cost) :
                                                      (transactionsAfter[i].Credit = transactionsAfter[i - 1].Credit);
                    }
                }

                if (Convert.ToBoolean(context.SaveChanges() > 0))
                {
                    TempData["ToasterState"]   = ToasterState.Success;
                    TempData["ToasterType"]    = ToasterType.Message;
                    TempData["ToasterMessage"] = Messages.EditTransactionSuccessful;
                }
                else
                {
                    TempData["ToasterState"]   = ToasterState.Error;
                    TempData["ToasterType"]    = ToasterType.Message;
                    TempData["ToasterMessage"] = Messages.EditTransactionFailed;
                }

                return(RedirectToAction("Index"));
            }

            return(BadRequest());
        }
 public void Mapping(Profile profile)
 {
     profile.CreateMap <ContactUs, GetAllContactUsMessagesDto>()
     .ForMember(d => d.ContactUsBusinessTypeCode, opt => opt.MapFrom(s => s.ContactUsBusinessTypeCode.DisplayName))
     .ForMember(d => d.CreationDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.CreationDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 20
0
            public async Task <PrimaryCategoriesVm> Handle(GetPrimaryCategoriesQuery request, CancellationToken cancellationToken)
            {
                IQueryable <Category> categories = _context.Category
                                                   .Where(x => !x.IsDelete);

                if (request.CategoryGuid.HasValue)
                {
                    Category category = await _context.Category
                                        .SingleOrDefaultAsync(x => x.CategoryGuid == request.CategoryGuid && !x.IsDelete, cancellationToken);

                    if (category == null)
                    {
                        return new PrimaryCategoriesVm()
                               {
                                   Message = "دسته بندی مورد نظر یافت نشد",
                                   State   = (int)GetPrimaryCategoriesState.CategoryNotFound
                               }
                    }
                    ;

                    categories = categories.Where(x => x.ParentCategoryId == category.CategoryId);
                }
                else
                {
                    categories = categories.Where(x => x.ParentCategoryId == null);
                }

                List <PrimaryCategoryDto> primaryCategories = await categories.OrderBy(x => x.Sort)
                                                              .Select(x => new PrimaryCategoryDto
                {
                    CategoryGuid  = x.CategoryGuid,
                    Title         = x.DisplayName,
                    Description   = x.Description,
                    Abstract      = x.Abstract,
                    Sort          = x.Sort,
                    CoverDocument = new FilepondDto
                    {
                        Source  = x.CoverDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.CoverDocument.Name,
                                Size = x.CoverDocument.Size.ToString(),
                                Type = x.CoverDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.CoverDocument.Path
                            }
                        }
                    },
                    ActiveIconDocument = new FilepondDto
                    {
                        Source  = x.CoverDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.ActiveIconDocument.Name,
                                Size = x.ActiveIconDocument.Size.ToString(),
                                Type = x.ActiveIconDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.ActiveIconDocument.Path
                            }
                        }
                    },
                    InactiveIconDocument = new FilepondDto
                    {
                        Source  = x.CoverDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.InactiveIconDocument.Name,
                                Size = x.InactiveIconDocument.Size.ToString(),
                                Type = x.InactiveIconDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.InactiveIconDocument.Path
                            }
                        }
                    },
                    QuadMenuDocument = new FilepondDto
                    {
                        Source  = x.CoverDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.QuadMenuDocument.Name,
                                Size = x.QuadMenuDocument.Size.ToString(),
                                Type = x.QuadMenuDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.QuadMenuDocument.Path
                            }
                        }
                    },
                    Tags = x.CategoryTag.OrderBy(x => x.Tag.Name)
                           .Select(x => new GetPrimaryCategoryTagNameDto
                    {
                        Guid = x.Tag.TagGuid,
                        Name = x.Tag.Name
                    }) as List <GetPrimaryCategoryTagNameDto>,
                    IsActive     = x.IsActive,
                    ModifiedDate = PersianDateExtensionMethods.ToPeString(x.ModifiedDate, "yyyy/MM/dd HH:mm")
                }).ToListAsync(cancellationToken);

                if (primaryCategories.Count <= 0)
                {
                    return new PrimaryCategoriesVm()
                           {
                               Message = "دسته بندی ای یافت نشد",
                               State   = (int)GetPrimaryCategoriesState.NotAnyCategoriesFound,
                           }
                }
                ;

                return(new PrimaryCategoriesVm()
                {
                    Message = "عملیات موفق آمیز",
                    State = (int)GetPrimaryCategoriesState.Success,
                    PrimaryCategories = primaryCategories
                });
            }
        }
    }
Ejemplo n.º 21
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <Payment, GetPaymentByGuidDto>()
     .ForMember(d => d.Contractor, opt => opt.MapFrom(s => s.Contractor.User.FirstName + " " + s.Contractor.User.LastName))
     .ForMember(d => d.CreationDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.CreationDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 22
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <Advertisement, GetAllAdvertisementsDto>()
     .ForMember(d => d.DocumentPath, opt => opt.MapFrom(s => s.Document.Path))
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 23
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <Complaint, GetAllComplaintsDto>()
     .ForMember(d => d.User, opt => opt.MapFrom(s => s.User.FirstName + " " + s.User.LastName))
     .ForMember(d => d.CreationDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.CreationDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 24
0
            private async Task <List <CategoryDto> > GetCategoryChildren(List <Category> categories, CategoryDto category)
            {
                List <CategoryDto> subCategories = categories
                                                   .Where(x => x.ParentCategoryId == category.CategoryId && !x.IsDelete)
                                                   .OrderBy(x => x.Sort)
                                                   .Select(x => new CategoryDto
                {
                    CategoryId    = x.CategoryId,
                    CategoryGuid  = x.CategoryGuid,
                    Title         = x.DisplayName,
                    Description   = x.Description,
                    Abstract      = x.Abstract,
                    Sort          = x.Sort,
                    CoverDocument = new FilepondDto
                    {
                        Source  = x.CoverDocument?.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.CoverDocument?.Name,
                                Size = x.CoverDocument?.Size.ToString(),
                                Type = x.CoverDocument?.TypeCode?.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.CoverDocument?.Path
                            }
                        }
                    },
                    ActiveIconDocument = new FilepondDto
                    {
                        Source  = x.ActiveIconDocument?.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.ActiveIconDocument?.Name,
                                Size = x.ActiveIconDocument?.Size.ToString(),
                                Type = x.ActiveIconDocument?.TypeCode?.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.ActiveIconDocument?.Path
                            }
                        }
                    },
                    InactiveIconDocument = new FilepondDto
                    {
                        Source  = x.InactiveIconDocument?.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.InactiveIconDocument?.Name,
                                Size = x.InactiveIconDocument?.Size.ToString(),
                                Type = x.InactiveIconDocument?.TypeCode?.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.InactiveIconDocument?.Path
                            }
                        }
                    },
                    QuadMenuDocument = new FilepondDto
                    {
                        Source  = x.QuadMenuDocument?.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.QuadMenuDocument?.Name,
                                Size = x.QuadMenuDocument?.Size.ToString(),
                                Type = x.QuadMenuDocument?.TypeCode?.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.QuadMenuDocument?.Path
                            }
                        }
                    },
                    Tags = x.CategoryTag.OrderBy(x => x.Tag.Name)
                           .Select(x => new GetCategoryTagNameDto
                    {
                        Guid = x.Tag.TagGuid,
                        Name = x.Tag.Name
                    }) as List <GetCategoryTagNameDto> ?? null,
                    IsActive     = x.IsActive,
                    ModifiedDate = PersianDateExtensionMethods.ToPeString(x.ModifiedDate, "yyyy/MM/dd HH:mm")
                }).ToList();

                if (subCategories.Count <= 0)
                {
                    return(new List <CategoryDto>());
                }

                category.Children = subCategories;

                foreach (CategoryDto subCategory in category.Children)
                {
                    subCategory.Children = await GetCategoryChildren(categories, subCategory);
                }

                return(category.Children);
            }
Ejemplo n.º 25
0
            public async Task <CategoryDtoResult> GetCategory(Guid parentGuid, bool includeChildren = false)
            {
                CategoryDto category = await _context.Category
                                       .Where(x => x.CategoryGuid == parentGuid && !x.IsDelete)
                                       .Select(x => new CategoryDto
                {
                    CategoryId    = x.CategoryId,
                    CategoryGuid  = x.CategoryGuid,
                    Title         = x.DisplayName,
                    Description   = x.Description,
                    Abstract      = x.Abstract,
                    Sort          = x.Sort,
                    CoverDocument = new FilepondDto
                    {
                        Source  = x.CoverDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.CoverDocument.Name,
                                Size = x.CoverDocument.Size.ToString(),
                                Type = x.CoverDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.CoverDocument.Path
                            }
                        }
                    },
                    ActiveIconDocument = new FilepondDto
                    {
                        Source  = x.ActiveIconDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.ActiveIconDocument.Name,
                                Size = x.ActiveIconDocument.Size.ToString(),
                                Type = x.ActiveIconDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.ActiveIconDocument.Path
                            }
                        }
                    },
                    InactiveIconDocument = new FilepondDto
                    {
                        Source  = x.InactiveIconDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.InactiveIconDocument.Name,
                                Size = x.InactiveIconDocument.Size.ToString(),
                                Type = x.InactiveIconDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.InactiveIconDocument.Path
                            }
                        }
                    },
                    QuadMenuDocument = new FilepondDto
                    {
                        Source  = x.QuadMenuDocument.Path,
                        Options = new FilepondOptions
                        {
                            Type  = "local",
                            Files = new FilepondFile
                            {
                                Name = x.QuadMenuDocument.Name,
                                Size = x.QuadMenuDocument.Size.ToString(),
                                Type = x.QuadMenuDocument.TypeCode.Name
                            },
                            Metadata = new FilepondMetadata
                            {
                                Poster = x.QuadMenuDocument.Path
                            }
                        }
                    },
                    Tags = x.CategoryTag.OrderBy(x => x.Tag.Name)
                           .Select(x => new GetCategoryTagNameDto
                    {
                        Guid = x.Tag.TagGuid,
                        Name = x.Tag.Name
                    }) as List <GetCategoryTagNameDto>,
                    IsActive     = x.IsActive,
                    ModifiedDate = PersianDateExtensionMethods.ToPeString(x.ModifiedDate, "yyyy/MM/dd HH:mm")
                }).SingleOrDefaultAsync();

                if (category == null)
                {
                    return(null);
                }

                if (includeChildren)
                {
                    List <Category> categories = await _context.Category
                                                 .Where(x => !x.IsDelete)
                                                 .ToListAsync();

                    if (categories.Count <= 0)
                    {
                        return(null);
                    }

                    category.Children = await GetCategoryChildren(categories, category);
                }
                else
                {
                    category.Children = new List <CategoryDto>();
                }

                return(new CategoryDtoResult()
                {
                    CategoryGuid = category.CategoryGuid,
                    Title = category.Title,
                    Abstract = category.Abstract,
                    Description = category.Description,
                    Sort = category.Sort,
                    CoverDocument = category.CoverDocument,
                    ActiveIconDocument = category.ActiveIconDocument,
                    InactiveIconDocument = category.InactiveIconDocument,
                    QuadMenuDocument = category.QuadMenuDocument,
                    Tags = category.Tags,
                    IsActive = category.IsActive,
                    ModifiedDate = category.ModifiedDate,
                    Children = category.Children
                });
            }
Ejemplo n.º 26
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <CodeGroup, GetAllCodeGroupsDto>()
     .ForMember(d => d.ModifiedDate, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.ModifiedDate, "yyyy/MM/dd HH:mm")));
 }
Ejemplo n.º 27
0
 public void Mapping(Profile profile)
 {
     profile.CreateMap <ChatMessage, GetChatMessagesDto>()
     .ForMember(d => d.From, opt => opt.MapFrom(s => s.User.Role.DisplayName))
     .ForMember(d => d.SentAt, opt => opt.MapFrom(s => PersianDateExtensionMethods.ToPeString(s.SentAt, "yyyy/MM/dd HH:mm")));
 }