Пример #1
0
 public async Task <bool> Delete(StoreGrouping StoreGrouping)
 {
     if (await ValidateId(StoreGrouping))
     {
     }
     return(StoreGrouping.IsValidated);
 }
Пример #2
0
        public virtual void DeleteGroupOutlet(StoreGrouping storeGrouping)
        {
            if (storeGrouping == null)
            {
                throw new ArgumentNullException(nameof(storeGrouping));
            }

            _storeGroupingRepository.Delete(storeGrouping);
        }
Пример #3
0
        public async Task InsertGroupOutlet(StoreGrouping storeGrouping)
        {
            if (storeGrouping == null)
            {
                throw new ArgumentNullException(nameof(storeGrouping));
            }

            await _storeGroupingRepository.InsertAsync(storeGrouping);
        }
Пример #4
0
        public async Task <StoreGrouping> Get(long Id)
        {
            StoreGrouping StoreGrouping = await UOW.StoreGroupingRepository.Get(Id);

            if (StoreGrouping == null)
            {
                return(null);
            }
            return(StoreGrouping);
        }
Пример #5
0
        public DirectSalesOrder_StoreGroupingDTO(StoreGrouping StoreGrouping)
        {
            this.Id = StoreGrouping.Id;

            this.Code = StoreGrouping.Code;

            this.Name = StoreGrouping.Name;

            this.ParentId = StoreGrouping.ParentId;

            this.Path = StoreGrouping.Path;

            this.Level    = StoreGrouping.Level;
            this.StatusId = StoreGrouping.StatusId;
        }
Пример #6
0
        public async Task <IActionResult> AddGroupOutlet(GroupOutletModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOutletManagement))
            {
                return(AccessDeniedView());
            }

            if (model.SelectedStoreIds.Count == 0)
            {
                ModelState.AddModelError(string.Empty, "Store is required");
                _notificationService.ErrorNotification("Store is required");
            }

            try
            {
                StoreGrouping storeGrouping = new StoreGrouping
                {
                    GroupName = model.GroupName,
                    Store     = new List <Store>()
                };
                _storeGroupingRepository.Update(storeGrouping);

                //Update store grouping
                var storeList = await _storeService.GetStores();

                foreach (var store in model.SelectedStoreIds)
                {
                    var stores = storeList.FirstOrDefault(s => s.P_BranchNo == store);
                    if (stores != null)
                    {
                        stores.StoreGroupingId = storeGrouping.Id;
                    }

                    await _storeService.UpdateStore(stores);
                }

                return(new NullJsonResult());
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                _notificationService.ErrorNotification(e.Message);

                return(Json(e.Message));
            }
        }
Пример #7
0
        public Store_StoreGroupingDTO(StoreGrouping StoreGrouping)
        {
            this.Id = StoreGrouping.Id;

            this.Code = StoreGrouping.Code;

            this.Name = StoreGrouping.Name;

            this.ParentId = StoreGrouping.ParentId;

            this.Path = StoreGrouping.Path;

            this.Level = StoreGrouping.Level;

            this.StatusId = StoreGrouping.StatusId;

            this.Errors = StoreGrouping.Errors;
        }
Пример #8
0
        public async Task <bool> ValidateId(StoreGrouping StoreGrouping)
        {
            StoreGroupingFilter StoreGroupingFilter = new StoreGroupingFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = StoreGrouping.Id
                },
                Selects = StoreGroupingSelect.Id
            };

            int count = await UOW.StoreGroupingRepository.Count(StoreGroupingFilter);

            if (count == 0)
            {
                StoreGrouping.AddError(nameof(StoreGroupingValidator), nameof(StoreGrouping.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Пример #9
0
        public Customer_StoreGroupingDTO(StoreGrouping StoreGrouping)
        {
            this.Id = StoreGrouping.Id;

            this.Code = StoreGrouping.Code;

            this.Name = StoreGrouping.Name;

            this.ParentId = StoreGrouping.ParentId;

            this.Path = StoreGrouping.Path;

            this.Level = StoreGrouping.Level;

            this.StatusId = StoreGrouping.StatusId;

            this.RowId = StoreGrouping.RowId;

            this.Used = StoreGrouping.Used;

            this.Errors = StoreGrouping.Errors;
        }
Пример #10
0
 public async Task <bool> Create(StoreGrouping StoreGrouping)
 {
     return(StoreGrouping.IsValidated);
 }
Пример #11
0
        public async Task <StoreGrouping> Get(long Id)
        {
            StoreGrouping StoreGrouping = await DataContext.StoreGrouping.AsNoTracking()
                                          .Where(x => x.Id == Id).Select(x => new StoreGrouping()
            {
                CreatedAt = x.CreatedAt,
                UpdatedAt = x.UpdatedAt,
                Id        = x.Id,
                Code      = x.Code,
                Name      = x.Name,
                ParentId  = x.ParentId,
                Path      = x.Path,
                Level     = x.Level,
                StatusId  = x.StatusId,
                Parent    = x.Parent == null ? null : new StoreGrouping
                {
                    Id       = x.Parent.Id,
                    Code     = x.Parent.Code,
                    Name     = x.Parent.Name,
                    ParentId = x.Parent.ParentId,
                    Path     = x.Parent.Path,
                    Level    = x.Parent.Level,
                    StatusId = x.Parent.StatusId,
                },
                Status = x.Status == null ? null : new Status
                {
                    Id   = x.Status.Id,
                    Code = x.Status.Code,
                    Name = x.Status.Name,
                },
            }).FirstOrDefaultAsync();

            if (StoreGrouping == null)
            {
                return(null);
            }
            StoreGrouping.Stores = await DataContext.Store.AsNoTracking()
                                   .Where(x => x.StoreGroupingId == StoreGrouping.Id)
                                   .Where(x => x.DeletedAt == null)
                                   .Select(x => new Store
            {
                Id                = x.Id,
                Code              = x.Code,
                CodeDraft         = x.CodeDraft,
                Name              = x.Name,
                UnsignName        = x.UnsignName,
                ParentStoreId     = x.ParentStoreId,
                OrganizationId    = x.OrganizationId,
                StoreTypeId       = x.StoreTypeId,
                StoreGroupingId   = x.StoreGroupingId,
                Telephone         = x.Telephone,
                ProvinceId        = x.ProvinceId,
                DistrictId        = x.DistrictId,
                WardId            = x.WardId,
                Address           = x.Address,
                UnsignAddress     = x.UnsignAddress,
                DeliveryAddress   = x.DeliveryAddress,
                Latitude          = x.Latitude,
                Longitude         = x.Longitude,
                DeliveryLatitude  = x.DeliveryLatitude,
                DeliveryLongitude = x.DeliveryLongitude,
                OwnerName         = x.OwnerName,
                OwnerPhone        = x.OwnerPhone,
                OwnerEmail        = x.OwnerEmail,
                TaxCode           = x.TaxCode,
                LegalEntity       = x.LegalEntity,
                AppUserId         = x.AppUserId,
                StatusId          = x.StatusId,
                Used              = x.Used,
                StoreStatusId     = x.StoreStatusId,
                AppUser           = new AppUser
                {
                    Id             = x.AppUser.Id,
                    Username       = x.AppUser.Username,
                    DisplayName    = x.AppUser.DisplayName,
                    Address        = x.AppUser.Address,
                    Email          = x.AppUser.Email,
                    Phone          = x.AppUser.Phone,
                    SexId          = x.AppUser.SexId,
                    Birthday       = x.AppUser.Birthday,
                    Avatar         = x.AppUser.Avatar,
                    Department     = x.AppUser.Department,
                    OrganizationId = x.AppUser.OrganizationId,
                    Longitude      = x.AppUser.Longitude,
                    Latitude       = x.AppUser.Latitude,
                    StatusId       = x.AppUser.StatusId,
                },
                District = new District
                {
                    Id         = x.District.Id,
                    Code       = x.District.Code,
                    Name       = x.District.Name,
                    Priority   = x.District.Priority,
                    ProvinceId = x.District.ProvinceId,
                    StatusId   = x.District.StatusId,
                },
                Organization = new Organization
                {
                    Id       = x.Organization.Id,
                    Code     = x.Organization.Code,
                    Name     = x.Organization.Name,
                    ParentId = x.Organization.ParentId,
                    Path     = x.Organization.Path,
                    Level    = x.Organization.Level,
                    StatusId = x.Organization.StatusId,
                    Phone    = x.Organization.Phone,
                    Email    = x.Organization.Email,
                    Address  = x.Organization.Address,
                },
                ParentStore = new Store
                {
                    Id                = x.ParentStore.Id,
                    Code              = x.ParentStore.Code,
                    CodeDraft         = x.ParentStore.CodeDraft,
                    Name              = x.ParentStore.Name,
                    UnsignName        = x.ParentStore.UnsignName,
                    ParentStoreId     = x.ParentStore.ParentStoreId,
                    OrganizationId    = x.ParentStore.OrganizationId,
                    StoreTypeId       = x.ParentStore.StoreTypeId,
                    StoreGroupingId   = x.ParentStore.StoreGroupingId,
                    Telephone         = x.ParentStore.Telephone,
                    ProvinceId        = x.ParentStore.ProvinceId,
                    DistrictId        = x.ParentStore.DistrictId,
                    WardId            = x.ParentStore.WardId,
                    Address           = x.ParentStore.Address,
                    UnsignAddress     = x.ParentStore.UnsignAddress,
                    DeliveryAddress   = x.ParentStore.DeliveryAddress,
                    Latitude          = x.ParentStore.Latitude,
                    Longitude         = x.ParentStore.Longitude,
                    DeliveryLatitude  = x.ParentStore.DeliveryLatitude,
                    DeliveryLongitude = x.ParentStore.DeliveryLongitude,
                    OwnerName         = x.ParentStore.OwnerName,
                    OwnerPhone        = x.ParentStore.OwnerPhone,
                    OwnerEmail        = x.ParentStore.OwnerEmail,
                    TaxCode           = x.ParentStore.TaxCode,
                    LegalEntity       = x.ParentStore.LegalEntity,
                    AppUserId         = x.ParentStore.AppUserId,
                    StatusId          = x.ParentStore.StatusId,
                    Used              = x.ParentStore.Used,
                    StoreStatusId     = x.ParentStore.StoreStatusId,
                },
                Province = new Province
                {
                    Id       = x.Province.Id,
                    Code     = x.Province.Code,
                    Name     = x.Province.Name,
                    Priority = x.Province.Priority,
                    StatusId = x.Province.StatusId,
                },
                Status = new Status
                {
                    Id   = x.Status.Id,
                    Code = x.Status.Code,
                    Name = x.Status.Name,
                },
                StoreStatus = new StoreStatus
                {
                    Id   = x.StoreStatus.Id,
                    Code = x.StoreStatus.Code,
                    Name = x.StoreStatus.Name,
                },
                StoreType = new StoreType
                {
                    Id       = x.StoreType.Id,
                    Code     = x.StoreType.Code,
                    Name     = x.StoreType.Name,
                    ColorId  = x.StoreType.ColorId,
                    StatusId = x.StoreType.StatusId,
                    Used     = x.StoreType.Used,
                },
                Ward = new Ward
                {
                    Id         = x.Ward.Id,
                    Code       = x.Ward.Code,
                    Name       = x.Ward.Name,
                    Priority   = x.Ward.Priority,
                    DistrictId = x.Ward.DistrictId,
                    StatusId   = x.Ward.StatusId,
                },
            }).ToListAsync();

            return(StoreGrouping);
        }
Пример #12
0
        public async Task <GroupOutletModel> PrepareGroupOutletModel(GroupOutletModel model, StoreGrouping storeGrouping)
        {
            if (storeGrouping != null)
            {
                model = model ?? new GroupOutletModel();

                model.Id               = storeGrouping.Id;
                model.GroupName        = storeGrouping.GroupName;
                model.SelectedStoreIds = storeGrouping.Store.Select(sgs => sgs.P_BranchNo).ToList();
                model.CreatedOn        = _dateTimeHelper.ConvertToUserTime(storeGrouping.CreatedOnUtc, DateTimeKind.Utc);
                model.LastActivityDate = _dateTimeHelper.ConvertToUserTime(storeGrouping.ModifiedOnUtc.GetValueOrDefault(DateTime.UtcNow), DateTimeKind.Utc);
            }

            var stores = await _storeService.GetStores();

            model.AvailableStores = stores.Select(store => new SelectListItem
            {
                Text  = store.P_BranchNo.ToString() + " - " + store.P_Name,
                Value = store.P_BranchNo.ToString()
            }).ToList();

            return(await Task.FromResult(model));
        }