public async Task <GetServiceForEditOutput> GetServiceForEdit(EntityDto input)
        {
            var service = await _serviceRepository.FirstOrDefaultAsync(input.Id);

            var output = new GetServiceForEditOutput {
                Service = ObjectMapper.Map <CreateOrEditServiceDto>(service)
            };

            if (output.Service.CategoryId != null)
            {
                var _lookupCategory = await _lookup_categoryRepository.FirstOrDefaultAsync((int)output.Service.CategoryId);

                output.CategoryName = _lookupCategory.Name.ToString();
            }

            if (output.Service.SysRefId != null)
            {
                var _lookupSysRef = await _lookup_sysRefRepository.FirstOrDefaultAsync((int)output.Service.SysRefId);

                output.SysRefRefCode = _lookupSysRef.RefCode.ToString();
            }

            return(output);
        }
示例#2
0
        public async Task <PartialViewResult> CreateOrUpdateServiceModal(long addressId, long?ownerId, string ownerType, int tenantId, long?id = null)
        {
            long num;
            IGenericAppService     genericAppService = this._genericAppService;
            NullableIdInput <long> nullableIdInput   = new NullableIdInput <long>()
            {
                Id = id
            };
            GetServiceForEditOutput serviceForEdit = await genericAppService.GetServiceForEdit(nullableIdInput);

            if (string.IsNullOrEmpty(serviceForEdit.Service.OwnerType))
            {
                serviceForEdit.Service.OwnerType = ownerType;
                ServiceEditDto service = serviceForEdit.Service;
                num             = (ownerId.HasValue ? ownerId.Value : (long)0);
                service.OwnerId = num;
                serviceForEdit.Service.AddressId = addressId;
            }
            CreateOrUpdateServiceModalViewModel createOrUpdateServiceModalViewModel = new CreateOrUpdateServiceModalViewModel(serviceForEdit);
            List <SelectListItem> selectListItems = new List <SelectListItem>();
            LookupFill            lookupFill      = new LookupFill("ServiceTypes", tenantId);

            foreach (Lookup lookupItem in lookupFill.LookupItems)
            {
                SelectListItem selectListItem = new SelectListItem()
                {
                    Text     = lookupItem.Text,
                    Value    = lookupItem.Value,
                    Disabled = lookupItem.Disabled,
                    Selected = lookupItem.Selected
                };
                selectListItems.Add(selectListItem);
            }
            SelectListItem selectListItem1 = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems.Insert(0, selectListItem1);
            this.ViewData["ServiceTypes"] = selectListItems;
            List <SelectListItem> selectListItems1 = new List <SelectListItem>();

            lookupFill = null;
            lookupFill = new LookupFill("RequestedServices", tenantId);
            foreach (Lookup lookup in lookupFill.LookupItems)
            {
                SelectListItem selectListItem2 = new SelectListItem()
                {
                    Text     = lookup.Text,
                    Value    = lookup.Value,
                    Disabled = lookup.Disabled,
                    Selected = lookup.Selected
                };
                selectListItems1.Add(selectListItem2);
            }
            SelectListItem selectListItem3 = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems1.Insert(0, selectListItem3);
            this.ViewData["RequestedServices"] = selectListItems1.AsEnumerable <SelectListItem>();
            return(this.PartialView("_CreateOrUpdateServiceModal", createOrUpdateServiceModalViewModel));
        }
 public CreateOrUpdateServiceModalViewModel(GetServiceForEditOutput output)
 {
     output.MapTo <GetServiceForEditOutput, CreateOrUpdateServiceModalViewModel>(this);
 }