Esempio n. 1
0
        public ActionResult Edit(int Id)
        {
            ContactInformationViewModel modelMap = Mapper.Map <ContactInformation, ContactInformationViewModel>(this._contactInfoService.GetById(Id));

            //Add Locales to model
            AddLocales(_languageService, modelMap.Locales, (locale, languageId) =>
            {
                locale.Id            = modelMap.Id;
                locale.Language      = modelMap.Language;
                locale.Title         = modelMap.GetLocalized(x => x.Title, Id, languageId, false, false);
                locale.Lag           = modelMap.Lag;
                locale.Lat           = modelMap.Lat;
                locale.Type          = modelMap.Type;
                locale.OrderDisplay  = modelMap.OrderDisplay;
                locale.Status        = modelMap.Status;
                locale.Email         = modelMap.Email;
                locale.Hotline       = modelMap.Hotline;
                locale.MobilePhone   = modelMap.MobilePhone;
                locale.Address       = modelMap.GetLocalized(x => x.Address, Id, languageId, false, false);
                locale.Fax           = modelMap.Fax;
                locale.NumberOfStore = modelMap.NumberOfStore;
                locale.ProvinceId    = modelMap.ProvinceId;
            });

            return(base.View(modelMap));
        }
        internal static MakerSpaceViewmodel Create(MakerSpace ms)
        {
            var msResponse = new MakerSpaceViewmodel();

            msResponse.Id           = ms.Id;
            msResponse.Name         = ms.Name;
            msResponse.WorkShopType = ms.WorkShopType;
            msResponse.Description  = ms.Description;
            if (!(ms.Address is null))
            {
                msResponse.Address = AddressViewmodel.Create(ms.Address);
            }
            if (!(ms.ContactInfo is null))
            {
                msResponse.ContactInformation = ContactInformationViewModel.Create(ms.ContactInfo);
            }
            msResponse.VATNumber = ms.VATNumber;
            msResponse.LogoUrl   = ms.Logo;
            ms.AccessType        = ms.AccessType;
            if (!string.IsNullOrWhiteSpace(ms.Organization))
            {
                msResponse.Organization = ms.Organization;
            }
            msResponse.Tools = ms.Tools.Select(x => x.Name).ToList();

            return(msResponse);
        }
Esempio n. 3
0
 public GetMakerSpaceByIdResponse(MakerSpace ms)
 {
     Id           = ms.Id;
     Name         = ms.Name;
     WorkShopType = ms.WorkShopType;
     Description  = ms.Description;
     if (!(ms.Address is null))
     {
         Address = AddressViewmodel.Create(ms.Address);
     }
     if (!(ms.ContactInfo is null))
     {
         ContactInformation = ContactInformationViewModel.Create(ms.ContactInfo);
     }
     VATNumber  = ms.VATNumber;
     LogoUrl    = ms.Logo.ToString();
     AccessType = ms.AccessType;
     if (!string.IsNullOrWhiteSpace(ms.Organization))
     {
         Organization = ms.Organization;
     }
     Tools   = ms.Tools.Select(x => x.Name).ToList();
     Members = ms.Members.Select(x => new UserVM {
         UserName = x.UserName, SchoolName = x.SchoolName
     }).ToList();
 }
            public static ContactInformationViewModel Create(ContactInfo contactInfo)
            {
                var ciVM = new ContactInformationViewModel();

                ciVM.Email = contactInfo.Email;
                ciVM.Phone = contactInfo.Phone;
                return(ciVM);
            }
        public ActionResult Create()
        {
            var model = new ContactInformationViewModel();

            //Add locales to model
            AddLocales(_languageService, model.Locales);

            return(View(model));
        }
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, ContactInformationViewModel contactInformation)
        {
            var contact = this.ShopData.ContactInformations.Find(contactInformation.Id);

            this.ShopData.ContactInformations.Delete(contact);
            this.ShopData.SaveChanges();

            return(this.Json(new[] { contactInformation }.ToDataSourceResult(request, this.ModelState)));
        }
Esempio n. 7
0
        public void ConvertContactInfoToViewmodel()
        {
            //Arrange
            var contactInfo = _requestFixture.Fixture.Create <ContactInfo>();

            //Act
            var ciVM = ContactInformationViewModel.Create(contactInfo);

            //Assert
            ciVM.Email.Should().Be(contactInfo.Email);
            ciVM.Phone.Should().Be(contactInfo.Phone);
        }
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, ContactInformationViewModel contactInformation)
        {
            this.ShopData.ContactInformations.Find(contactInformation.Id);
            this.TryUpdateModel(contactInformation);

            if (this.ModelState.IsValid)
            {
                this.ShopData.SaveChanges();
            }

            return(this.Json(new[] { contactInformation }.ToDataSourceResult(request, this.ModelState)));
        }
        public ActionResult Add(
            [DataSourceRequest] DataSourceRequest request, ContactInformationViewModel contactInformation)
        {
            var userId = this.User.Identity.GetUserId();
            var user   = this.ShopData.Users.Find(userId);

            if (contactInformation == null || !this.ModelState.IsValid)
            {
                return(this.Json(new[] { contactInformation }.ToDataSourceResult(request, this.ModelState)));
            }

            var newInfo = GetNewContactInformation(contactInformation, user);

            user.Adresses.Add(newInfo);
            this.ShopData.SaveChanges();

            return(this.Json(new[] { contactInformation }.ToDataSourceResult(request, this.ModelState)));
        }
Esempio n. 10
0
        public ActionResult Create(ContactInformationViewModel model, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                                  .Select(v => v.ErrorMessage + " " + v.Exception));
                    base.ModelState.AddModelError("", messages);
                    return(base.View(model));
                }
                else
                {
                    ContactInformation modelMap = Mapper.Map <ContactInformationViewModel, ContactInformation>(model);
                    this._contactInfoService.Create(modelMap);

                    //Update Localized
                    foreach (var localized in model.Locales)
                    {
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Address, localized.Address, localized.LanguageId);
                    }

                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.ContactInformation)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ExtentionUtils.Log(string.Concat("MailSetting.Create: ", exception.Message));
                return(base.View(model));
            }
            return(action);
        }
        private static ContactInformation GetNewContactInformation(ContactInformationViewModel contactInformation, ApplicationUser user)
        {
            var newInfo = new ContactInformation
            {
                ContactName   = contactInformation.ContactName,
                Address1      = contactInformation.Address1,
                Address2      = contactInformation.Address2,
                City          = contactInformation.City,
                Country       = contactInformation.Country,
                Company       = contactInformation.Company,
                PhoneNumber   = contactInformation.PhoneNumber,
                StateProvince = contactInformation.StateProvince,
                ZipCode       = contactInformation.StateProvince,
                ContactPerson = contactInformation.ContactPerson,
                Email         = contactInformation.ContactPerson,
                FaxNumber     = contactInformation.FaxNumber
            };

            return(newInfo);
        }
Esempio n. 12
0
        public async Task ReturnUnpopulatedContactInformationViewModelIfOrganizationIsNull()
        {
            var sut = new OrganizationContactQueryHandler(Context);

            var message = new OrganizationContactQuery {
                OrganizationId = 2
            };

            var result = await sut.Handle(message);

            result.ShouldNotBeNull();
            result.ShouldBeOfType <ContactInformationViewModel>();

            var contactInfo = new ContactInformationViewModel();

            Assert.True(result.FirstName == contactInfo.FirstName &&
                        result.LastName == contactInfo.LastName &&
                        result.Email == contactInfo.Email &&
                        result.Location == contactInfo.Location &&
                        result.PhoneNumber == contactInfo.PhoneNumber);
        }
Esempio n. 13
0
 public void SetUp()
 {
     contactInformationVIewModelFixture = new ContactInformationViewModel();
 }