Пример #1
0
        public async Task <ActionResult <ContactPerson> > PostContactPerson(ContactPerson contactPerson)
        {
            _context.ContactPersons.Add(contactPerson);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetContactPerson), new { id = contactPerson.Id }, contactPerson));
        }
Пример #2
0
        public async Task <IActionResult> PutContactPerson(int id, ContactPerson contactPerson)
        {
            if (id != contactPerson.Id)
            {
                return(BadRequest());
            }

            _context.Entry(contactPerson).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactPersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
 private void MapToContact(ContactPerson cp, ContactViewModel model)
 {
     cp.FirstName   = model.FirstName;
     cp.LastName    = model.LastName;
     cp.Email       = model.Email;
     cp.CellphoneNr = model.CellphoneNr;
 }
Пример #4
0
        internal static ContactPersonList getContactPersonList(HttpResponseMessage responce)
        {
            var contactPersonList = new ContactPersonList();
            var jsonObj           =
                JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("contact_persons"))
            {
                var contactPersonsArray =
                    JsonConvert.DeserializeObject <List <object> >(jsonObj["contact_persons"].ToString());
                foreach (var contactPersonObj in contactPersonsArray)
                {
                    var contactPerson = new ContactPerson();
                    contactPerson = JsonConvert.DeserializeObject <ContactPerson>(contactPersonObj.ToString());
                    contactPersonList.Add(contactPerson);
                }
            }
            if (jsonObj.ContainsKey("page_context"))
            {
                var pageContext = new PageContext();
                pageContext = JsonConvert.DeserializeObject <PageContext>(jsonObj["page_context"].ToString());
                contactPersonList.page_context = pageContext;
            }
            return(contactPersonList);
        }
Пример #5
0
        public ActionResult CreateContactPerson()
        {
            ContactPerson    cp  = new ContactPerson();
            ContactViewModel cvm = new ContactViewModel(cp);

            return(View(cvm));
        }
Пример #6
0
        public ActionResult DeleteContactPersonConfirmed(int id, DeleteContactPersonViewModel model)
        {
            try
            {
                ContactPerson cp = contactRepo.FindById(id);
                if (cp == null)
                {
                    TempData["error"] = "There was e problem deleting the contact person. Please contact the IT department.";
                    RedirectToAction("Index");
                }

                //Changing the contactperson to a new one before deleting it.
                ContactPerson newContact = contactRepo.FindById(model.SelectedContactId);
                cp.Hotels.ToList().ForEach(t =>
                {
                    t.ContactPerson = newContact;
                });

                contactRepo.RemoveContactPerson(cp);
                contactRepo.SaveChanges();
                TempData["message"] = String.Format("The contact {0} is succesfully deleted", cp.LastName + cp.FirstName);
                RedirectToAction("Index");
            }catch (Exception ex)
            {
                TempData["error"] = "There was a problem deleting the contact person. Please contact the IT department.";
            }

            return(RedirectToAction("Index"));
        }
Пример #7
0
        public void GivenCreateParkingLotDTOReturnFromParkingLot_WhenGivenParkinglotDTOReturnToCreate_ThenCreateParkingLotDTOReturn()
        {
            var              memstub     = Substitute.For <IMemberServices>();
            var              stubpark    = Substitute.For <IParkingLotMapper>();
            var              stubAddress = Substitute.For <IAddressMapper>();
            AddressMapper    addressmap  = new AddressMapper(new CityMapper(memstub));
            ParkingLotMapper parkmap     = new ParkingLotMapper(new AddressMapper(new CityMapper(memstub)), new ContactPersonMapper(new AddressMapper(new CityMapper(memstub))));

            var city          = City.CreateCity(2050, "Antwerpen", "Belgium");
            var contactPerson = ContactPerson.CreateNewContactPerson("lasr", "peelman", Address.CreateAddress("test", "5", city), "*****@*****.**", "5454548564", "5456456456");

            var parkinglot = ParkingLotBuilder.CreateNewParkingLot()
                             .WithBuildingType(BuildingType.AboveGround)
                             .WithCapacity(5)
                             .WithContactPerson(contactPerson)
                             .WithDivision(new Guid())
                             .WithName("lasr")
                             .WithPricePerHour(5.00M)
                             .WithAddress(Address.CreateAddress("test", "5", city))
                             .Build();

            var result = parkmap.FromParkingLotToParkingLotDTOReturn(parkinglot);

            Assert.IsType <ParkingLotDTO_Return>(result);
        }
 public DeleteContactPersonViewModel(ContactPerson cp)
 {
     Id             = cp.ContactPersonId;
     LastName       = cp.LastName;
     FirstName      = cp.FirstName;
     NumberOfHotels = cp.Hotels.Count();
 }
Пример #9
0
        public static AddressTestBO CreateSavedAddress(ContactPerson contactPerson, string firstLine)
        {
            AddressTestBO address = CreateUnsavedAddress(contactPerson, firstLine);

            address.Save();
            return(address);
        }
Пример #10
0
        public VendorViewModel()
        {
            Vendor = new VendorInfo();

            Vendors = new List <VendorInfo>();

            Cities = new List <CityInfo>();

            Designations = new List <DesignationInfo>();

            Business = new List <BusinessInfo>();

            BusinessList = new List <BusinessInfo>();

            Filter = new VendorFilter();

            ContactFilter = new ContactPersonFilter();

            BankFilter = new BankFilter();

            Pager = new PaginationInfo();

            FriendlyMessage = new List <FriendlyMessage>();

            ContactPerson = new ContactPerson();

            ContactPersons = new List <ContactPerson>();

            PaymentOptionList = new List <VendorInfo>();
        }
Пример #11
0
        public static AddressTestBO CreateSavedAddress(ContactPerson contactPerson)
        {
            AddressTestBO address = CreateUnsavedAddress(contactPerson);

            address.Save();
            return(address);
        }
Пример #12
0
        public async Task <IHttpActionResult> PutContactPerson(int id, ContactPerson contactPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != contactPerson.Id)
            {
                return(BadRequest());
            }

            db.Entry(contactPerson).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactPersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #13
0
        /// <summary>
        /// Sends an email with calendar event.
        /// </summary>
        /// <param name="mail">The mail.</param>
        /// <param name="isBodyHtml">if set to <c>true</c> [is body HTML].</param>
        /// <returns></returns>
        public bool SendMail(string subject, ContactPerson details, List <AttachmentFile> attachments, string applicationReciever, string applicationSender)
        {
            var         content     = BuildEmailContent(details);
            MailMessage mailMessage = BuildMail(applicationSender, subject, content, applicationReciever, applicationReciever, GetAttachments(attachments));

            return(SendMail(mailMessage, true));
        }
Пример #14
0
        private string HandleMCSVerifyUA(string data, MCSListenerToken token)
        {
            string      tempStr     = data.Remove(0, CommonFlag.F_MCSVerifyUA.Length);
            ClientModel clientModel = CommonVariables.serializer.Deserialize <ClientModel>(tempStr);

            if (clientModel != null)
            {
                if (!string.IsNullOrEmpty(clientModel.ObjectID))
                {
                    ContactPerson contactPerson = token.ContactPersonService.FindContactPerson(clientModel.ObjectID);
                    if (contactPerson != null)
                    {
                        //CommonVariables.LogTool.Log(contactPerson.UpdateTime + " VS" + clientModel.UpdateTime);
                        if (contactPerson.UpdateTime.CompareTo(clientModel.UpdateTime) == 0)
                        {
                            CommonVariables.MessageContorl.AddClientModel(clientModel);

                            //CommonVariables.LogTool.Log(clientModel.ObjectID + " VS" + clientModel.LatestTime + "VS" + clientModel.MDS_IP);

                            CommonVariables.MessageContorl.SendGetMsgToMDS(clientModel);
                            return("ok");
                        }
                    }
                    return("wait");
                }
            }
            return(string.Empty);
        }
Пример #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (userAction != (int)Enums.UserAction.Add)
                {
                    model = clientRepo.GetContactPersonByID(contactPersonID);

                    if (model != null)
                    {
                        GetClientProvider().SetContactPersonModel(model);
                        FillForm();
                    }
                }

                UserActionConfirmBtnUpdate(btnConfirmPopup, userAction, true);
            }
            else
            {
                if (model == null && SessionHasValue(Enums.SupplierSession.ContactPersonModel))
                {
                    model = GetClientProvider().GetContactPersonModel();
                }
            }
        }
Пример #16
0
        public void CreateTestPack()
        {
            SetupDBConnection();
            new Engine();
            new Address();
            ContactPerson.DeleteAllContactPeople();
            new Car();
            CreateUpdatedContactPersonTestPack();


            _contactPersonUpdateConcurrency = new ContactPerson();
            _contactPersonUpdateConcurrency.Surname = "Update Concurrency";
            _contactPersonUpdateConcurrency.Save();


            _contactPBeginEditsConcurrency = new ContactPerson();
            _contactPBeginEditsConcurrency.Surname = "BeginEdits Concurrency";
            _contactPBeginEditsConcurrency.Save();

            _contactPTestRefreshFromObjMan = new ContactPerson();
            _contactPTestRefreshFromObjMan.Surname = "FirstSurname";
            _contactPTestRefreshFromObjMan.Save();
            new Engine();
            CreateDeletedPersonTestPack();
            CreateSaveContactPersonTestPack();
  
            //Ensure that a fresh object is loaded from DB
            FixtureEnvironment.ClearBusinessObjectManager();
        }
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] ContactPerson model)
        {
            foreach (var error in await _repo.GetModelErrors(model))
            {
                ModelState.AddModelError(error.Key, error.Value);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dbModel = await _repo.GetById(id);

            if (dbModel == null)
            {
                return(NotFound());
            }
            if (!_authentication.HasAccess(HttpContext, dbModel))
            {
                return(Unauthorized());
            }

            model.Id = id;                                         // Don't allow the ID to be changed
            _authentication.SetAuthentication(HttpContext, model); // Ensure that the authentication is added to this model

            try {
                await _repo.Update(model);
            } catch (KeyNotFoundException) {
                return(NotFound());
            }

            return(NoContent());
        }
Пример #18
0
        public async Task <IActionResult> Create(ContactModuleViewModel contactModuleViewModel)
        {
            if (ModelState.IsValid)
            {
                Module module = new Module()
                {
                    ModuleTitle  = contactModuleViewModel.ModuleTitle,
                    PositionId   = (int)contactModuleViewModel.PositionId,
                    IsActive     = contactModuleViewModel.IsActive,
                    Accisibility = contactModuleViewModel.Accisibility,
                    ComponentId  = 4
                };


                //Method for selecting menus for modules
                foreach (var item in await _menuService.Menus())
                {
                    if (Request.Form["Page[" + item.MenuId.ToString() + "]"].Any())
                    {
                        ModulePage modulePage = new ModulePage()
                        {
                            MenuId = item.MenuId,
                        };
                        module.ModulePage.Add(modulePage);
                    }
                }

                //for ContactModule inserting
                module.ContactModule = new ContactModule()
                {
                    Email       = contactModuleViewModel.Email,
                    PostCode    = contactModuleViewModel.PostCode,
                    PhoneNum    = contactModuleViewModel.PhoneNum,
                    MobileNum   = contactModuleViewModel.MobileNum,
                    Description = contactModuleViewModel.Description,
                    Address     = contactModuleViewModel.Address,
                };

                //for Users included contactModule inserting
                List <ContactPerson> contactPeople = new List <ContactPerson>();
                foreach (var item in await _userService.GetAllAdmin())
                {
                    if (Request.Form["User[" + item.UserId.ToString() + "]"].Any())
                    {
                        ContactPerson contactPerson = new ContactPerson()
                        {
                            UserId = item.UserId,
                        };
                        module.ContactModule.ContactPerson.Add(contactPerson);
                    }
                }

                //Add the Module
                await _moduleService.Add(module);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PositionId"] = new SelectList(await _positionService.GetAll(), "PositionId", "PositionTitle");
            return(View(contactModuleViewModel));
        }
        public void Test_ReturnSameObjectFromBusinessObjectLoader()
        {
            //---------------Set up test pack-------------------
            //------------------------------Setup Test
            new Engine();
            new Car();
            ContactPerson originalContactPerson = new ContactPerson();
            originalContactPerson.Surname = "FirstSurname";
            originalContactPerson.Save();

            FixtureEnvironment.ClearBusinessObjectManager();

            //load second object from DB to ensure that it is now in the object manager
            ContactPerson myContact2 =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPerson>
                    (originalContactPerson.ID);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ContactPerson myContact3 =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPerson>
                    (originalContactPerson.ID);

            //---------------Test Result -----------------------
//                Assert.AreNotSame(originalContactPerson, myContact3);
            Assert.AreSame(myContact2, myContact3);
        }
Пример #20
0
        public void GivenGetSingleParkingLot_WhenRequestingSingleParkingLot_ReturnRequestedParkingLot()
        {
            using (var context = new ParkSharkDbContext(CreateNewInMemoryDatabase()))
            {
                var city       = City.CreateCity(2050, "Antwerpen", "Belgium");
                var service    = new ParkingLotService(context);
                var parkingLot = ParkingLotBuilder.CreateNewParkingLot()
                                 .WithName("test")
                                 .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city))
                                 .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", ""))
                                 .WithCapacity(20)
                                 .WithDivision(Guid.NewGuid())
                                 .WithPricePerHour(4.5m)
                                 .Build();
                context.Set <ParkingLot>().Add(parkingLot);
                var id = parkingLot.ParkingLotID;
                context.SaveChanges();

                var result = service.GetSingleParkingLot(id);

                Assert.IsType <ParkingLot>(result);
                Assert.Equal(id, result.ParkingLotID);
                Assert.Equal("test", result.Name);
            }
        }
Пример #21
0
        public Response Update(ContactPerson data, bool isCommit = true)
        {
            string   message = "Failed";
            bool     result  = false;
            Response res     = new Response();

            var findData = db.ContactPerson.Where(x => x.UserID == data.UserID && x.DeletedDate == null).FirstOrDefault();

            if (findData != null)
            {
                findData.Email = data.Email;
                findData.Name  = data.Name;

                if (isCommit)
                {
                    db.SaveChanges();

                    message = "Save Data Company success";
                    result  = true;
                }
            }

            res.Message = message;
            res.Result  = result;

            return(res);
        }
Пример #22
0
        public void GivenGetAllParkingLots_WhenRequestingAllParkingLots_ThenReturnListOfAllParkingLots()
        {
            using (var context = new ParkSharkDbContext(CreateNewInMemoryDatabase()))
            {
                var city = City.CreateCity(2050, "Antwerpen", "Belgium");

                var parkingLot1 = ParkingLotBuilder.CreateNewParkingLot()
                                  .WithName("test")
                                  .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city))
                                  .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", ""))
                                  .WithCapacity(20)
                                  .WithDivision(Guid.NewGuid())
                                  .WithPricePerHour(4.5m)
                                  .Build();
                var parkingLot2 = ParkingLotBuilder.CreateNewParkingLot()
                                  .WithName("test2")
                                  .WithAddress(Address.CreateAddress("Parkinglotstraat", "20a", city))
                                  .WithContactPerson(ContactPerson.CreateNewContactPerson("Bas", "Adriaans", Address.CreateAddress("Contactpersoonstraat", "30", city), "*****@*****.**", "000000", ""))
                                  .WithCapacity(20)
                                  .WithDivision(Guid.NewGuid())
                                  .WithPricePerHour(4.5m)
                                  .Build();
                context.Set <ParkingLot>().Add(parkingLot1);
                context.Set <ParkingLot>().Add(parkingLot2);
                context.SaveChanges();

                var service = new ParkingLotService(context);
                var result  = context.ParkingLots.CountAsync();
                Assert.Equal(2, result.Result);
            }
        }
Пример #23
0
 public bool saveContactPerson(ref ContactPerson contactPerson, ref string returnMessage, int userId)
 {
     result = false;
     using (KarachiNPcontext)
     {
         if (contactPerson != null && contactPerson.ContactPersonId > 0)//Edit
         {
             int           contactPersonId   = contactPerson.ContactPersonId;
             ContactPerson objContactPersont = KarachiNPcontext.ContactPersons.Where(a => a.ContactPersonId == contactPersonId).FirstOrDefault();
             objContactPersont.ContactName             = contactPerson.ContactName;
             objContactPersont.ContactPersonDepartment = contactPerson.ContactPersonDepartment;
             if (contactPerson.ImageUrl != null && contactPerson.ImageUrl != "")
             {
                 objContactPersont.ImageUrl = contactPerson.ImageUrl;
             }
             objContactPersont.contactNumber = contactPerson.contactNumber;
             objContactPersont.ContactEmail  = contactPerson.ContactEmail;
             objContactPersont.ModifiedBy    = userId;
             objContactPersont.ModifiedDate  = DateTime.Now;
             objContactPersont.IsActive      = contactPerson.IsActive;
             result = true;
         }
         else
         {
             contactPerson.CreatedBy   = userId;
             contactPerson.CreatedDate = DateTime.Now;
             KarachiNPcontext.ContactPersons.Add(contactPerson);
             result = true;
         }
         KarachiNPcontext.SaveChanges();
         int id = contactPerson.ContactPersonId;
         contactPerson = KarachiNPcontext.ContactPersons.Where(a => a.ContactPersonId == id).FirstOrDefault();
         return(result);
     }
 }
Пример #24
0
        public async Task <ActionResult <ContactPerson> > Update([FromBody] ContactPerson _ContactPerson)
        {
            ContactPerson _ContactPersonq = _ContactPerson;

            try
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    try
                    {
                        _ContactPersonq = await(from c in _context.ContactPerson
                                                .Where(q => q.ContactPersonId == _ContactPerson.ContactPersonId)
                                                select c
                                                ).FirstOrDefaultAsync();

                        _context.Entry(_ContactPersonq).CurrentValues.SetValues((_ContactPerson));

                        //_context.Alert.Update(_Alertq);
                        await _context.SaveChangesAsync();

                        BitacoraWrite _write = new BitacoraWrite(_context, new Bitacora
                        {
                            IdOperacion  = _ContactPerson.ContactPersonId,
                            DocType      = "ContactPerson",
                            ClaseInicial =
                                Newtonsoft.Json.JsonConvert.SerializeObject(_ContactPersonq, new JsonSerializerSettings {
                                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                            }),
                            ResultadoSerializado = Newtonsoft.Json.JsonConvert.SerializeObject(_ContactPerson, new JsonSerializerSettings {
                                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                            }),
                            Accion              = "Actualizar",
                            FechaCreacion       = DateTime.Now,
                            FechaModificacion   = DateTime.Now,
                            UsuarioCreacion     = _ContactPerson.CreatedUser,
                            UsuarioModificacion = _ContactPerson.ModifiedUser,
                            UsuarioEjecucion    = _ContactPerson.ModifiedUser,
                        });

                        await _context.SaveChangesAsync();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                        throw ex;
                        // return BadRequest($"Ocurrio un error:{ex.Message}");
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}")));
            }

            return(await Task.Run(() => Ok(_ContactPersonq)));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Email,Name,PhoneNumber")] ContactPerson contactPerson)
        {
            if (id != contactPerson.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try {
                    _context.Update(contactPerson);
                    await _context.SaveChangesAsync();
                } catch (DbUpdateConcurrencyException) {
                    if (!ContactPersonExists(contactPerson.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contactPerson));
        }
Пример #26
0
        public void Update(
            ILogger logger,
            ContactPerson sourcePowerofficeContactPerson,
            long sourcePowerofficeCustomerId,
            int webcrmOrganisationId,
            PowerofficeConfiguration configuration)
        {
            PersonDirectPhone      = sourcePowerofficeContactPerson.PhoneNumber;
            PersonEmail            = sourcePowerofficeContactPerson.EmailAddress;
            PersonFirstName        = sourcePowerofficeContactPerson.FirstName;
            PersonAdjustedLastName = sourcePowerofficeContactPerson.LastName;

            // It is not allowed to change the organisation ID of a person.
            if (PersonOrganisationId == null)
            {
                PersonOrganisationId = webcrmOrganisationId;
            }
            else if (PersonOrganisationId != webcrmOrganisationId)
            {
                logger.LogWarning($"The PowerOffice contact person with ID '{sourcePowerofficeContactPerson.Id}' has changed webCRM organisation from '{PersonOrganisationId}' to '{webcrmOrganisationId}'. We cannot change the organisation ID through the API, so this is not synchronised.");
            }

            var personKey = new PowerofficePersonKey(sourcePowerofficeCustomerId, sourcePowerofficeContactPerson.Id);

            SetPowerofficePersonKey(configuration.PersonIdFieldName, personKey);

            MarkAsPrimaryContact(configuration.PrimaryContactCheckboxFieldName);
        }
        public ContactPerson AddContactPerson(string surname, string firstname, string middlename, string phone, string email,
                                              string country, string city, string street, string building, string index,
                                              Company company)
        {
            ContactPerson p = new ContactPerson
            {
                Surname    = surname,
                FirstName  = firstname,
                MiddleName = middlename,
                Phone      = phone,
                Email      = email,
                Adress     =
                {
                    Country = country,
                    City    = city,
                    Street  = street,
                    Bilding = building,
                    Index   = index
                },
                Company = company
            };

            cont.Person.Add(p);
            cont.SaveChanges();
            return(p);
        }
Пример #28
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Naam,Functie,Telefoonnummer,EmailAdres,ImageUrl,CountryId,ProvinceId")] ContactPerson contactPerson)
        {
            if (id != contactPerson.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contactPerson);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactPersonExists(contactPerson.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"]  = new SelectList(_context.Countries, "Id", "Id", contactPerson.CountryId);
            ViewData["ProvinceId"] = new SelectList(_context.Counties, "Id", "Id", contactPerson.ProvinceId);
            return(View(contactPerson));
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (BuyerId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PrimaryPhone?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (SecondaryPhone?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Fax?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (WebSite?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Company?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AnnualTurnOver?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LegalRepresentative?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Rating?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CreditInsurance.GetHashCode());
            hashCode = hashCode * -1521134295 + (Logo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AddressOne?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AddressTwo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (VatNumber?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ContactPerson?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Prefix?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Temp?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (UserName?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PasswordHash?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (SecurityStamp?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (EmailConfirmed.GetHashCode());
            hashCode = hashCode * -1521134295 + (LockoutEnabled.GetHashCode());
            hashCode = hashCode * -1521134295 + (PhoneNumberConfirmed.GetHashCode());
            hashCode = hashCode * -1521134295 + (TwoFactorEnabled.GetHashCode());
            hashCode = hashCode * -1521134295 + (AccessFailedCount?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Name?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Email?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PhoneNumber?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LockoutEndDate?.GetHashCode() ?? 0);
            return(hashCode);
        }
Пример #30
0
        public IActionResult New(int?bankId)
        {
            if (bankId != null)
            {
                BankSaveModel bankSaveModel = new BankSaveModel();

                Bank bank = _bankService.Set().Single(s => s.ID == bankId);
                bankSaveModel.BankModel = new BankModel()
                {
                    ID   = bank.ID,
                    Name = bank.Name,
                    URL  = bank.URL
                };

                ContactPerson contactPerson = _contactPersonService.Set().Single(s => s.BankID == bankId && s.PositionID == _positionService.Set().Single(ss => ss.Name.Equals("General Director")).ID);
                bankSaveModel.ContactPersonModel = new ContactPersonModel()
                {
                    FirstName   = contactPerson.FirstName,
                    LastName    = contactPerson.LastName,
                    DateOfBirth = contactPerson.DateOfBirth
                };

                return(View(bankSaveModel));
            }
            return(View(new BankSaveModel()));
        }
        public void Test_ReturnSameObjectFromBusinessObjectLoader()
        {
            //---------------Set up test pack-------------------
            //------------------------------Setup Test
            new Engine();
            new Car();
            ContactPerson originalContactPerson = new ContactPerson();

            originalContactPerson.Surname = "FirstSurname";
            originalContactPerson.Save();

            FixtureEnvironment.ClearBusinessObjectManager();

            //load second object from DB to ensure that it is now in the object manager
            ContactPerson myContact2 =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPerson>
                    (originalContactPerson.ID);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            ContactPerson myContact3 =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPerson>
                    (originalContactPerson.ID);

            //---------------Test Result -----------------------
//                Assert.AreNotSame(originalContactPerson, myContact3);
            Assert.AreSame(myContact2, myContact3);
        }
Пример #32
0
        public ContactPerson Remove(ContactPerson contactPerson)
        {
            var removedContactPerson = _contactPersonContext.ContactPersons.Remove(contactPerson);

            _contactPersonContext.SaveChanges();
            return(removedContactPerson);
        }
Пример #33
0
        private void CreateSaveContactPersonTestPack()
        {
            _contactPTestSave = new ContactPerson();
            _contactPTestSave.DateOfBirth = new DateTime(1980, 01, 22);
            _contactPTestSave.FirstName = "Brad";
            _contactPTestSave.Surname = "Vincent1";

            _contactPTestSave.Save(); //save the object to the DB
        }
Пример #34
0
        /// <summary>
        /// Generate a sample MetadataBase.
        /// </summary>
        /// <remarks>
        /// In a production system this would be generated from the STS configuration.
        /// </remarks>
        public static MetadataBase GetFederationMetadata()
        {
            string endpointId = "http://localhost:61754/";
            EntityDescriptor metadata = new EntityDescriptor();
            metadata.EntityId = new EntityId(endpointId);

            // Define the signing key
            string signingCertificateName = WebConfigurationManager.AppSettings["SigningCertificateName"];
            X509Certificate2 cert = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, signingCertificateName);
            metadata.SigningCredentials = new X509SigningCredentials(cert);

            // Create role descriptor for security token service
            SecurityTokenServiceDescriptor stsRole = new SecurityTokenServiceDescriptor();
            stsRole.ProtocolsSupported.Add(new Uri(WSFederationMetadataConstants.Namespace));
            metadata.RoleDescriptors.Add(stsRole);

            // Add a contact name
            ContactPerson person = new ContactPerson(ContactType.Administrative);
            person.GivenName = "contactName";
            stsRole.Contacts.Add(person);

            // Include key identifier for signing key in metadata
            SecurityKeyIdentifierClause clause = new X509RawDataKeyIdentifierClause(cert);
            SecurityKeyIdentifier ski = new SecurityKeyIdentifier(clause);
            KeyDescriptor signingKey = new KeyDescriptor(ski);
            signingKey.Use = KeyType.Signing;
            stsRole.Keys.Add(signingKey);

            // Add endpoints
            string activeSTSUrl = "http://localhost:61754/";
            EndpointAddress endpointAddress = new EndpointAddress(new Uri(activeSTSUrl),
                                                                   null,
                                                                   null, GetMetadataReader(activeSTSUrl), null);
            stsRole.SecurityTokenServiceEndpoints.Add(endpointAddress);

            // Add a collection of offered claims
            // NOTE: In this sample, these claims must match the claims actually generated in CustomSecurityTokenService.GetOutputClaimsIdentity.
            //       In a production system, there would be some common data store that both use
            stsRole.ClaimTypesOffered.Add(new DisplayClaim(ClaimTypes.Name, "Name", "The name of the subject."));
            stsRole.ClaimTypesOffered.Add(new DisplayClaim(ClaimTypes.Role, "Role", "The role of the subject."));
            // Add a special claim for the QuoteService
            stsRole.ClaimTypesOffered.Add(new DisplayClaim(QuotationClassClaimType, "QuotationClass", "Class of quotation desired."));

            return metadata;
        }
Пример #35
0
        // Creates an IdP entity descriptor
        private static EntityDescriptor CreateIDPEntityDescriptor()
        {
            EntityDescriptor entityDescriptor = new EntityDescriptor();
            entityDescriptor.EntityID = new EntityIDType("http://www.idp.com");
            entityDescriptor.IDPSSODescriptors.Add(CreateIDPSSODescriptor());

            Organization organization = new Organization();
            organization.OrganizationNames.Add(new OrganizationName("IdP", "en"));
            organization.OrganizationDisplayNames.Add(new OrganizationDisplayName("IdP", "en"));
            organization.OrganizationURLs.Add(new OrganizationURL("www.idp.com", "en"));
            entityDescriptor.Organization = organization;

            ContactPerson contactPerson = new ContactPerson();
            contactPerson.ContactTypeValue = "technical";
            contactPerson.GivenName = "Joe";
            contactPerson.Surname = "User";
            contactPerson.EmailAddresses.Add("*****@*****.**");
            entityDescriptor.ContactPeople.Add(contactPerson);

            return entityDescriptor;
        }
        public void TestLoadFromDatabaseAlwaysLoadsSameObject()
        {
            //---------------Set up test pack-------------------
            new Engine();
            new Car();
            ContactPerson originalContactPerson = new ContactPerson();
            const string firstSurname = "FirstSurname";
            originalContactPerson.Surname = firstSurname;
            originalContactPerson.Save();
            IPrimaryKey origConactPersonID = originalContactPerson.ID;
            originalContactPerson = null;
            FixtureEnvironment.ClearBusinessObjectManager();
            TestUtil.WaitForGC();

            //load second object from DB to ensure that it is now in the object manager
            ContactPerson loadedContactPerson1 =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPerson>(origConactPersonID);

            //---------------Assert Precondition----------------
            Assert.IsNull(originalContactPerson);
            Assert.AreEqual(firstSurname, loadedContactPerson1.Surname);
            Assert.AreNotSame(originalContactPerson, loadedContactPerson1);
            Assert.AreEqual(1, BORegistry.BusinessObjectManager.Count);

            //---------------Execute Test ----------------------

            ContactPerson loadedContactPerson2 =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPerson>(origConactPersonID);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, BORegistry.BusinessObjectManager.Count);
            Assert.AreEqual(firstSurname, loadedContactPerson2.Surname);
            Assert.AreNotSame(originalContactPerson, loadedContactPerson2);

            Assert.AreSame(loadedContactPerson1, loadedContactPerson2);
        }
Пример #37
0
 public static AddressTestBO CreateSavedAddress(ContactPerson contactPerson, string firstLine)
 {
     AddressTestBO address = CreateUnsavedAddress(contactPerson, firstLine);
     address.Save();
     return address;
 }
Пример #38
0
        public static AddressTestBO CreateUnsavedAddress(ContactPerson contactPerson, string firstLine)
        {
            return CreateUnsavedAddress(contactPerson.ContactPersonID, firstLine);

        }
Пример #39
0
 public static AddressTestBO CreateSavedAddress(ContactPerson contactPerson)
 {
     AddressTestBO address = CreateUnsavedAddress(contactPerson);
     address.Save();
     return address;
 }
Пример #40
0
        public void TestGetPropDef_WithSource_TwoLevels()
        {
            //---------------Set up test pack-------------------

            IClassDef engineClassDef = Engine.LoadClassDef_IncludingCarAndOwner();
            ClassDef contactPersonClassDef = new ContactPerson().ClassDef;
            Source source = Source.FromString("Car.Owner");
            const string surnamePropName = "Surname";
            //---------------Execute Test ----------------------
            IPropDef surnamePropDef = engineClassDef.GetPropDef(source, surnamePropName, false);
            //---------------Test Result -----------------------
            Assert.AreSame(contactPersonClassDef.PropDefcol[surnamePropName], surnamePropDef);
            //---------------Tear Down -------------------------
        }
Пример #41
0
 private void CreateUpdatedContactPersonTestPack()
 {
     ContactPerson myContact = new ContactPerson();
     myContact.DateOfBirth = new DateTime(1969, 01, 29);
     myContact.FirstName = "FirstName";
     myContact.Surname = "Surname";
     myContact.Save();
     _updateContactPersonId = myContact.ID;
 }
Пример #42
0
        public void TestDeleteFlagsSetContactPerson()
        {
            ContactPerson myContact = new ContactPerson();
            Assert.IsTrue(myContact.Status.IsNew); // this object is new
            myContact.DateOfBirth = new DateTime(1980, 01, 22);
            myContact.FirstName = "Brad";
            myContact.Surname = "Vincent4";

            myContact.Save(); //save the object to the DB
            Assert.IsFalse(myContact.Status.IsNew); // this object is saved and thus no longer
            // new
            Assert.IsFalse(myContact.Status.IsDeleted);

            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);
            myContact.MarkForDelete();
            Assert.IsTrue(myContact.Status.IsDeleted);
            myContact.Save();
            Assert.IsTrue(myContact.Status.IsDeleted);
            Assert.IsTrue(myContact.Status.IsNew);
        }
Пример #43
0
        public void TestCreateContactPerson()
        {
            ContactPerson myContact = new ContactPerson();
            Assert.IsNotNull(myContact);
            myContact.DateOfBirth = new DateTime(1980, 01, 22);
            myContact.FirstName = "Brad";
            myContact.Surname = "Vincent3";

            Assert.AreEqual("Brad", myContact.FirstName);
            Assert.AreEqual(new DateTime(1980, 01, 22), myContact.DateOfBirth);
        }
Пример #44
0
        public void TestForDuplicateNewObjectsSinglePropKeyNull()
        {
            //create the first object
            ContactPerson myContact_1 = new ContactPerson();

            //Edit first object and save
            myContact_1.Surname = "My Surname SinglePropKeyNull";
            myContact_1.SetPropertyValue("PK3Prop", null); // set the previous value to null
            myContact_1.Save(); //
            //get the second new object from the object manager
            ContactPerson myContact_2 = new ContactPerson();
            //set this new object to have the same 
            // data as the already saved object
            myContact_2.Surname = "My Surname SinglePropKeyNull";
            myContact_2.SetPropertyValue("PK3Prop", myContact_1.GetPropertyValue("PK3Prop"));
            // set the previous value to null

            try
            {
                myContact_2.Save();
                Assert.Fail("Expected to throw an BusObjDuplicateConcurrencyControlException");
            }
                //---------------Test Result -----------------------
            catch (BusObjDuplicateConcurrencyControlException ex)
            {
                StringAssert.Contains("A 'Contact Person' already exists with the same identifier", ex.Message);
            }
        }
Пример #45
0
        public void TestEditTwoInstancesContactPerson()
        {
            ContactPerson myContact = new ContactPerson();
            myContact.DateOfBirth = new DateTime(1980, 01, 22);
            myContact.FirstName = "Brad";
            myContact.Surname = "Vincent5";

            myContact.Save(); //save the object to the DB

            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);

            ContactPerson mySecondContactPerson =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<ContactPerson>(id);

            Assert.AreEqual(myContact.ID,
                            mySecondContactPerson.ID);
            Assert.AreEqual(myContact.FirstName, mySecondContactPerson.FirstName);
            Assert.AreEqual(myContact.DateOfBirth, mySecondContactPerson.DateOfBirth);

            //Change the MyContact's Surname see if mySecondContactPerson is changed.
            //this should change since the second contact person was obtained from object manager and 
            // these should thus be the same instance.
            myContact.Surname = "New Surname";
            Assert.AreEqual(myContact.Surname, mySecondContactPerson.Surname);
        }
Пример #46
0
 public void TestObjectCompulsorySurnameNotSet()
 {
     //---------------Set up test pack-------------------
     ContactPerson myContact = new ContactPerson();
     //---------------Execute Test ----------------------
     try
     {
         myContact.Save();
         Assert.Fail("Expected to throw an BusObjectInAnInvalidStateException");
     }
         //---------------Test Result -----------------------
     catch (BusObjectInAnInvalidStateException ex)
     {
         StringAssert.Contains("'ContactPerson.Surname' is a compulsory field and has no value", ex.Message);
     }
 }
Пример #47
0
 public void TestObjectSurnameTooLong()
 {
     //---------------Set up test pack-------------------
     ContactPerson myContact = new ContactPerson();
     myContact.Surname = "MyPropertyIsTooLongByFarThisWill Cause and Error in Bus object";
     //---------------Execute Test ----------------------
     try
     {
         myContact.Save();
         Assert.Fail("Expected to throw an BusObjectInAnInvalidStateException");
     }
         //---------------Test Result -----------------------
     catch (BusObjectInAnInvalidStateException ex)
     {
         StringAssert.Contains("for property 'ContactPerson.Surname' is not valid for the rule 'ContactPerson-Surname'", ex.Message);
     }
 }
Пример #48
0
 public void TestStateAfterApplyEdit()
 {
     ContactPerson myContact = new ContactPerson();
     myContact.Surname = "Test Surname";
     myContact.Save();
     Assert.IsFalse(myContact.Status.IsNew, "BO is still IsNew after being saved.");
 }
 public void TestUpdatesProperties_GivenBo_WithoutUserNameAndDate()
 {
     //-------------Setup Test Pack ------------------
     new Engine(); new Car();
     ContactPerson contactPerson = new ContactPerson();
     contactPerson.Props.Remove("DateLastUpdated");
     contactPerson.Props.Remove("UserLastUpdated");
     contactPerson.CancelEdits();
     ISecurityController securityController = new MySecurityController();
     GlobalRegistry.SecurityController = securityController;
     BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson);
     //-------------Test Pre-conditions --------------
     //-------------Execute test ---------------------       
     log.Update();
     //-------------Test Result ----------------------
     //Should give no errors.
 }
Пример #50
0
        public void TestCancelEdits()
        {
            ContactPerson myContact = new ContactPerson();

            Assert.IsFalse(myContact.Status.IsValid());
            myContact.Surname = "My Surname";
            Assert.IsTrue(myContact.Status.IsValid());
            Assert.AreEqual("My Surname", myContact.Surname);
            myContact.CancelEdits();
            Assert.IsFalse(myContact.Status.IsValid());
            Assert.IsTrue(myContact.Surname.Length == 0);
        }
 public void TestUpdatesProperties_GivenBo_UserNameAndDate_AndSecurityController()
 {
     //-------------Setup Test Pack ------------------
     
     new Engine(); new Car();
     ContactPerson contactPerson = new ContactPerson();
     IBOProp dateBoProp = contactPerson.Props["DateLastUpdated"];
     IBOProp userBoProp = contactPerson.Props["UserLastUpdated"];
     contactPerson.CancelEdits();
     ISecurityController securityController = new MySecurityController();
     BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson, securityController);
     //-------------Test Pre-conditions --------------
     //-------------Execute test ---------------------       
     DateTime beforeUpdate = DateTime.Now;
     log.Update();
     DateTime afterUpdate = DateTime.Now;
     //-------------Test Result ----------------------
     Assert.IsNotNull(userBoProp.Value);
     Assert.AreEqual("MyUserName", userBoProp.Value);
     Assert.IsNotNull(dateBoProp.Value);
     Assert.IsTrue(beforeUpdate <= (DateTime)dateBoProp.Value);
     Assert.IsTrue(afterUpdate >= (DateTime)dateBoProp.Value);
 }
Пример #52
0
 public static AddressTestBO CreateUnsavedAddress(ContactPerson contactPerson)
 {
     return CreateUnsavedAddress(contactPerson.ContactPersonID);
 }
Пример #53
0
        public void TestForDuplicateNewObjects()
        {
            //create the first object
            ContactPerson myContact_1 = new ContactPerson();

            //Edit first object and save
            myContact_1.FirstName = "My FirstName";
            myContact_1.Surname = "My Surname";
            myContact_1.SetPropertyValue("PK2Prop1", "PK2Prop1Value1" + TestUtil.GetRandomString());
            myContact_1.SetPropertyValue("PK2Prop2", "PK2Prop1Value2" + TestUtil.GetRandomString());
            myContact_1.Save(); //
            //get the second new object from the object manager;
            ContactPerson myContact_2 = new ContactPerson();
            //set this new object to have the same 
            // data as the already saved object
            myContact_2.Surname = "My Surname";
            myContact_2.SetPropertyValue("PK2Prop1", myContact_1.GetPropertyValue("PK2Prop1"));
            myContact_2.SetPropertyValue("PK2Prop2", myContact_1.GetPropertyValue("PK2Prop2"));

            try
            {
                myContact_2.Save();
                Assert.Fail("Expected to throw an BusObjDuplicateConcurrencyControlException");
            }
                //---------------Test Result -----------------------
            catch (BusObjDuplicateConcurrencyControlException ex)
            {
                StringAssert.Contains("A 'Contact Person' already exists with the same identifier", ex.Message);
            }
        }
Пример #54
0
        private static void CreateDeletedPersonTestPack()
        {
            ContactPerson myContact = new ContactPerson();
            myContact.DateOfBirth = new DateTime(1980, 01, 22);
            myContact.FirstName = "Brad";
            myContact.Surname = "Vincent2";

            myContact.Save(); //save the object to the DB
            myContact.MarkForDelete();
            myContact.Save();
        }