예제 #1
0
 public void Update(Agency agency)
 {
     agency.Name = OrganisationName;
     agency.UserName = UserName;
     agency.Password = Password;
     agency.Email = Email;
 }
예제 #2
0
 private Agency GetAgency(SignupViewModel viewModel)
 {
     var agency = new Agency();
     viewModel.Update(agency);
     agencyService.CreateNewAgency(agency);
     viewModel.UpdateSuburbs(agency.MetaProduct);
     return agency;
 }
예제 #3
0
 public void Update(Agency agency)
 {
     agency.Name = Name;
     agency.UserName = UserName;
     agency.Password = Password;
     agency.Email = Email;
     agency.Role = RoleNames.agency;
 }
예제 #4
0
 private void SaveAgency(Agency agency)
 {
     saver.AddToContext(agency);
     saver.SaveAll();
     agencyService.UpdateAgencyIds(agency);
     saver.SaveAll();
     agencyService.CreateNewAgencyFileSystemObjects(agency);
     SetSuccessMessage("New Agency created successfully.");
 }
예제 #5
0
 private bool ValidateAgency(Agency agency)
 {
     if (!agency.IsValid)
     {
         SetModelErrors(agency, "Save failed.");
         return false;
     }
     if (agencyService.IsExistingUsername(agency.UserName))
     {
         ModelState.AddModelError("UserName", "Invalid username. Please try another.");
         SetModelErrors(agency, "Save failed.");
         return false;
     }
     return true;
 }
예제 #6
0
        public ActionResult CreateNewAgency(NewAgencyViewModel model, FormCollection form)
        {
            if (!ModelState.IsValid) return ViewNewAgencyForm(model,"Save failed.");

            var agency = new Agency();
            model.Update(agency);
            agencyService.CreateNewAgency(agency);
            if (!agency.IsValid) return ViewNewAgencyForm(model, "Save failed.", agency);
            saver.AddToContext(agency);
            saver.SaveAll();
            agencyService.UpdateAgencyIds(agency);
            saver.SaveAll();
            agencyService.CreateNewAgencyFileSystemObjects(agency);
            SetSuccessMessage("Saved.");
            return RedirectToAction("Menu");
        }
 public void CreateNewAgency_setup()
 {
     agencyRepoMock = new Mock<IAgencyRepository>();
     context = new Mock<ICanAddToContext>();
     agency = new Agency
     {
         Name = "Test Name",
         UserName = "******",
         Password = "******",
         Email = "test",
         Role = RoleNames.agency
     };
     fileSystem = new Mock<IFileSystemService>();
     fileSystem.Expect(f => f.CreateDirectory(It.IsAny<string>())).Verifiable();
     fileSystem.Expect(f => f.CreateDirectory(It.IsAny<string>())).Verifiable();
     fileSystem.Expect(f => f.CopyFile(It.IsAny<string>(), It.IsAny<string>())).Verifiable();
     agencyService = new AgencyService(agencyRepoMock.Object, context.Object, fileSystem.Object);
 }
예제 #8
0
 /// <summary> Creates the meta product (including meta attributes)</summary>
 public void CreateNewAgency(Agency agency)
 {
     var metaProduct = MetaProduct.GetDefaultMetaProduct();
     context.AddToContext(metaProduct);
     metaProduct.MetaAttributes.ToList().ForEach(ma => context.AddToContext(ma));
     agency.SetMetaProduct(metaProduct);
 }
예제 #9
0
 public void UpdateAgencyIds(Agency agency)
 {
     agency.AgencyId = agency.Id;
     agency.MetaProduct.AgencyId = agency.Id;
     agency.MetaProduct.MetaAttributes.ToList().ForEach(ma => ma.AgencyId = agency.Id);
 }
예제 #10
0
 public void Setup()
 {
     hostAgency = new AgencyBuilder().WithRole(RoleNames.host).WithName("Host Agency").Build();
     ViewMapper.ConfigureAutomapper();
 }
예제 #11
0
 public void UpdateAgency(Agency agency)
 {
     agency.Name = Name;
     agency.Password = Password;
     agency.Email = Email;
 }
예제 #12
0
 public ProfileViewModel(Agency agency)
 {
     Name = agency.Name;
     UserName = agency.UserName;
     Password = agency.Password;
     RetypePassword = agency.Password;
     Email = agency.Email;
     LogoRelative = agency.LogoRelative;
 }
예제 #13
0
 partial void UpdateAgency(Agency instance);
예제 #14
0
 private ViewResult ViewNewAgencyForm(NewAgencyViewModel model, string errorMessage, Agency agency)
 {
     SetModelErrors(agency);
     return ViewNewAgencyForm(model, errorMessage);
 }
예제 #15
0
 partial void DeleteAgency(Agency instance);
예제 #16
0
 public void CreateNewAgencyFileSystemObjects(Agency agency)
 {
     fileSystem.CreateDirectory(agency.ContentDirectory);
     fileSystem.CreateDirectory(agency.TemplateDirectory);
     fileSystem.CopyFile(AppDomain.CurrentDomain.BaseDirectory + "\\Content\\Message.vm", Path.Combine(agency.TemplateDirectory, "Message.vm"));
 }
예제 #17
0
        private bool SaveLogo(Agency agency)
        {
            HttpPostedFileBase newLogo = Request.Files["newLogo"];
            if (newLogo == null || newLogo.ContentLength == 0) return true;

            if (!newLogo.IsImageFileType())
            {
                SetErrorMessage("Invalid logo file type. Valid types are: .jpg, .jpeg, .gif and .png.");
                return false;
            }
            newLogo.SaveAs(Server.MapPath(agency.ContentDirectoryRelative + newLogo.FileName));
            agency.LogoFileName = newLogo.FileName;
            return true;
        }
예제 #18
0
 partial void InsertAgency(Agency instance);