Exemplo n.º 1
0
        public void CreateProductTest()
        {
            var contactController = new ContactController(_contactService)
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "v1/Contacts/Contact/Create")
                }
            };

            contactController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var newContact = new ContactEntity()
            {
                FirstName = "Rackson"
            };

            var maxProductIDBeforeAdd = _contacts.Max(a => a.ID);

            newContact.ID = maxProductIDBeforeAdd + 1;
            contactController.Post(newContact);
            var addedcontact = new Contact()
            {
                FirstName = newContact.FirstName, ID = newContact.ID
            };

            AssertObjects.PropertyValuesAreEquals(addedcontact, _contacts.Last());
            Assert.That(maxProductIDBeforeAdd + 1, Is.EqualTo(_contacts.Last().ID));
        }
        public void Given_ContactService_AddContact()
        {
            //Arrange
            int Id      = 1;
            var contact = new ContactEntity()
            {
                ID          = 1,
                FirstName   = "Rahul",
                LastName    = "Patel",
                Email       = "*****@*****.**",
                PhoneNumber = "9623252606",
                IsActive    = true
            };

            this.mockRepository.Setup(m => m.Add(contact)).Returns((ContactEntity e) =>
            {
                e.ID = Id;
                return(e);
            });

            var contactObject = mapper.Object.GetObject(contact);

            //Act
            this.service.CreateContact(contactObject);

            //Assert
            Assert.AreEqual(Id, contact.ID);
            this.mockUnitWork.Verify(m => m.Commit(), Times.Once);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Default data bind.
        /// </summary>
        private void PreBindSteps()
        {
            rbSourceType.Items.Add(new ListItem(" " + GetGlobalResourceObject("IbnFramework.Common", "imExcel").ToString(), "0"));
            rbSourceType.Items.Add(new ListItem(" " + GetGlobalResourceObject("IbnFramework.Common", "imXML").ToString(), "1"));
            rbSourceType.Items.Add(new ListItem(" " + GetGlobalResourceObject("IbnFramework.Common", "imCSV").ToString(), "2"));
            if (String.Compare(_className, ContactEntity.GetAssignedMetaClassName(), true) == 0)
            {
                rbSourceType.Items.Add(new ListItem(" " + GetGlobalResourceObject("IbnFramework.Common", "imVCF").ToString(), "3"));
            }

            CHelper.SafeSelect(rbSourceType, "0");

            ddDelimeter.Items.Add(new ListItem(",", ","));
            ddDelimeter.Items.Add(new ListItem(".", "."));
            ddDelimeter.Items.Add(new ListItem(";", ";"));
            ddDelimeter.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "tSpaceValue").ToString(), "space"));
            ddDelimeter.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "tTabValue").ToString(), "tab"));

            ddTextQualifier.Items.Add(new ListItem("\"", "\""));
            ddTextQualifier.Items.Add(new ListItem("'", "'"));

            ddEncoding.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "tDefault").ToString(), "Default"));
            ddEncoding.Items.Add(new ListItem("ASCII", "ASCII"));
            ddEncoding.Items.Add(new ListItem("UTF-8", "UTF8"));
            ddEncoding.Items.Add(new ListItem("Unicode", "Unicode"));
        }
Exemplo n.º 4
0
        // GET: Contact/Create
        public IActionResult Create()
        {
            ContactEntity contact_blank = new ContactEntity();
            AdresseEntity adresse_blank = new AdresseEntity();

            return(View(GetDTO(contact_blank, adresse_blank)));
        }
Exemplo n.º 5
0
        private ContactWithAdresseDTOAndId GetDTOWithId(ContactEntity contact, AdresseEntity adresse)
        {
            var _dto = _mapper.Map <ContactWithAdresseDTOAndId>(contact);

            _dto.Adresse = _mapper.Map <AdresseDTOWithId>(adresse);
            return(_dto);
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, ContactWithAdresseDTOAndId _dtoWithId)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    AdresseEntity adresse_db = _mapper.Map <AdresseEntity>(_dtoWithId.Adresse);
                    ContactEntity contact_db = _mapper.Map <ContactEntity>(_dtoWithId);
                    contact_db.Adresse = adresse_db;

                    await _service_contact.Update(contact_db);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactEntityExists(_dtoWithId.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(_dtoWithId));
        }
        /// <summary>
        /// Add user contact
        /// </summary>
        /// <param name="contactEntity">Contact Entity</param>
        /// <returns>Contact Id</returns>
        public string AddContact(ContactEntity contactEntity)
        {
            ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) => true;

            var url     = _baseUrl + "users/addressbooks/personal?key=" + _accessToken;
            var client  = new RestClient(url);
            var request = new RestRequest(Method.POST);

            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json",
                                 " {\"contact\":" +
                                 JsonConvert.SerializeObject(contactEntity)
                                 + "\n}",
                                 ParameterType.RequestBody);

            // execute the request
            IRestResponse response       = client.Execute(request);
            var           responseObject = (dynamic)JsonConvert.DeserializeObject(response.Content);

            if (responseObject != null && responseObject.result != null)
            {
                return(responseObject.result.contact_id);
            }

            return(string.Empty);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> PutContactForm(long id, ContactEntity contactForm)
        {
            if (id != contactForm.Id)
            {
                return(BadRequest());
            }

            var contact = await _context.ContactItems.FindAsync(id);

            if (contact == null)
            {
                return(NotFound());
            }

            contact.CompleteName = contactForm.CompleteName;
            contact.Mail         = contactForm.Mail;
            contact.Phone        = contactForm.Phone;
            contact.Message      = contact.Message;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!ContactFormExists(id))
            {
                return(NotFound());
            }

            return(NoContent());
        }
Exemplo n.º 9
0
        /// <summary>
        /// Contact Upd
        /// </summary>
        public static async Task <ContactEntity> ContactUpd(ContactEntity item, string userGuid, string serviceGroupGuid)
        {
            try
            {
                var pixMakeRepository = await PixMakeMySqlRepository.GetConnection();

                var result = await pixMakeRepository.QueryFirstOrDefaultAsync <ContactEntity>(
                    "pm_contact_upd", new
                {
                    contact_guid_in       = item.contact_guid,
                    service_group_guid_in = serviceGroupGuid,
                    user_guid_in          = userGuid,
                    contact_type_guid_in  = item.contact_type_guid,
                    contact_info_in       = item.contact_info
                },
                    commandType : CommandType.StoredProcedure);

                pixMakeRepository.Close();
                return(result);
            }
            catch (Exception ex)
            {
                await SendError.SendErrorAsync(ex, customMessage : "MySql");

                return(null);
            }
        }
Exemplo n.º 10
0
        protected void VerifySaved(ContactEntity entity)
        {
            var model = _context.Contacts.SingleOrDefault(x => x.Id == entity.Id.Value);

            Assert.IsNotNull(model);
            Assert.AreEqual(entity.Name.FirstName, model.FirstName);
            Assert.AreEqual(entity.Name.LastName, model.LastName);

            var emails = _context.ContactEmails.Where(x => x.ContactId == entity.Id.Value).Select(x => x.Email).ToList();

            Assert.AreEqual(entity.EmailAddresses.Count, emails.Count);

            foreach (var email in emails)
            {
                Assert.IsTrue(entity.EmailAddresses.Contains(new EmailValueObject(email)));
            }

            var phones = _context.ContactPhones.Where(x => x.ContactId == entity.Id.Value).ToList();

            Assert.AreEqual(entity.PhoneNumbers.Count, phones.Count);

            foreach (var phone in phones)
            {
                Assert.IsTrue(entity.PhoneNumbers.Contains(new PhoneValueObject(phone.PhoneType, phone.PhoneNumber)));
            }
        }
Exemplo n.º 11
0
        private void BindDictionaries()
        {
            lbCategory.DataSource     = Document.GetListCategoriesAll();
            lbCategory.DataTextField  = "CategoryName";
            lbCategory.DataValueField = "CategoryId";
            lbCategory.DataBind();

            // Priority
            ddlPriority.DataSource     = Document.GetListPriorities();
            ddlPriority.DataTextField  = "PriorityName";
            ddlPriority.DataValueField = "PriorityId";
            ddlPriority.DataBind();

            if (ProjectId > 0)
            {
                lblProject.Text = Project.GetProjectTitle(ProjectId);
            }

            if (DocumentId <= 0)
            {
                ListItem liPriority = ddlPriority.Items.FindByValue(PortalConfig.DocumentDefaultValuePriorityField);
                if (liPriority != null)
                {
                    liPriority.Selected = true;
                }

                ucTaskTime.Value = DateTime.MinValue.AddMinutes(int.Parse(PortalConfig.DocumentDefaultValueTaskTimeField));

                ArrayList list = Common.StringToArrayList(PortalConfig.DocumentDefaultValueGeneralCategoriesField);
                foreach (int i in list)
                {
                    CommonHelper.SafeMultipleSelect(lbCategory, i.ToString());
                }

                PrimaryKeyId org_id     = PrimaryKeyId.Empty;
                PrimaryKeyId contact_id = PrimaryKeyId.Empty;
                Common.GetDefaultClient(PortalConfig.DocumentDefaultValueClientField, out contact_id, out org_id);
                if (contact_id != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = contact_id;
                }
                else if (org_id != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = org_id;
                }

                rbFile.Checked = true;
                rbFile.Attributes.Add("onclick", "ShowFile()");
                rbHTML.Attributes.Add("onclick", "ShowHTML()");
                rbLink.Attributes.Add("onclick", "ShowLink()");
                rbFile.Text    = LocRM.GetString("File");
                rbHTML.Text    = LocRM.GetString("HTMLText");
                rbLink.Text    = LocRM.GetString("Link");
                rbHTML.Checked = false;
                rbLink.Checked = false;
                Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script>window.setTimeout('ShowFile()', 200);</script>");
            }
        }
Exemplo n.º 12
0
        private void ConvertVCardPhones(int vcardId, ContactEntity contact)
        {
            VCardTelephone[] phones = VCardTelephone.List(vcardId);
            foreach (VCardTelephone phone in phones)
            {
                switch (phone.TelephoneType)
                {
                case VCardTelephoneTypes.Cell:
                    SafelySetStringProperty(contact, "MobilePhone", phone.Number);
                    break;

                case VCardTelephoneTypes.Fax:
                    SafelySetStringProperty(contact, "Fax", phone.Number);
                    break;

                case VCardTelephoneTypes.Pref:
                    SafelySetStringProperty(contact, "Telephone1", phone.Number);
                    break;

                case VCardTelephoneTypes.Work:
                    SafelySetStringProperty(contact, "Telephone2", phone.Number);
                    break;

                case VCardTelephoneTypes.Home:
                    SafelySetStringProperty(contact, "Telephone3", phone.Number);
                    break;
                }
            }
        }
Exemplo n.º 13
0
        public async Task <ContactEntity> DeleteAsync(ContactEntity item)
        {
            _context.Remove(item);
            await _context.SaveChangesAsync();

            return(item);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Saves an entity.
        /// </summary>
        /// <param name="entity">The resource entity to save.</param>
        /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param>
        /// <returns>The changing result information.</returns>
        public override async Task <ChangingResultInfo> SaveAsync(ContactEntity entity, CancellationToken cancellationToken = default)
        {
            if (entity == null)
            {
                return(new ChangingResultInfo(ChangeErrorKinds.Argument, EntityNullTips));
            }
            if (string.IsNullOrWhiteSpace(UserId))
            {
                return(new ChangingResultInfo(ChangeErrorKinds.Unauthorized, LoginErrorTips));
            }
            if (string.IsNullOrWhiteSpace(entity.OwnerId) && entity.IsNew)
            {
                entity.OwnerId = UserId;
            }
            try
            {
                var result = await DataProvider.SaveAsync(entity, cancellationToken);

                if (ResourceEntityExtensions.IsSuccessful(result))
                {
                    return(new ChangingResultInfo <ContactEntity>(result, entity, result.ToString() + " contact entity."));
                }
                return(result);
            }
            catch (Exception ex)
            {
                var err = ResourceEntityExtensions.TryCatch(ex);
                if (err != null)
                {
                    return(err);
                }
                throw;
            }
        }
Exemplo n.º 15
0
        public async Task <ContactEntity> UpdateAsync(ContactEntity item)
        {
            _context.Update(item);
            await _context.SaveChangesAsync();

            return(item);
        }
Exemplo n.º 16
0
        public async Task <ContactEntity> AddAsync(ContactEntity item)
        {
            _context.ContactEntities.Add(item);
            await _context.SaveChangesAsync();

            return(item);
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,FirstName,LastName,Email")] ContactEntity contactEntity)
        {
            if (id != contactEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contactEntity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactEntityExists(contactEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contactEntity));
        }
Exemplo n.º 18
0
        public static bool ModifyContact(ContactEntity entity)
        {
            int result = 0;

            if (entity != null)
            {
                ContactRepository mr = new ContactRepository();

                ContactInfo info = TranslateContactInfo(entity);


                if (entity.ContactID > 0)
                {
                    result = mr.ModifyContact(info);
                }
                else
                {
                    info.CreateDate = DateTime.Now;
                    result          = mr.CreateNew(info);
                }

                List <ContactInfo> miList = mr.GetAllContact();//刷新缓存
                Cache.Add("ContactALL", miList);
            }
            return(result > 0);
        }
        public bool UpdateContact(int Id, ContactEntity contactEntity)
        {
            var success = false;

            if (contactEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var contact = _unitOfWork.ContactRepository.GetByID(Id);
                    if (contact != null)
                    {
                        contact.FirstName   = contactEntity.FirstName;
                        contact.LastName    = contactEntity.LastName;
                        contact.Address     = contactEntity.Address;
                        contact.Email       = contactEntity.Email;
                        contact.PhoneNumber = contactEntity.PhoneNumber;
                        contact.Status      = contactEntity.Status.ToString();
                        _unitOfWork.ContactRepository.Update(contact);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
Exemplo n.º 20
0
        public void Update(IContact contact)
        {
            var            contactEntity = new ContactEntity(contact, _partitionKey);
            TableOperation saveOperation = TableOperation.InsertOrReplace(contactEntity);

            _table.Execute(saveOperation);
        }
Exemplo n.º 21
0
        public async Task <APIResponse> SaveContact([FromBody] ContactEntity objContact)
        {
            APIResponse objResponse = new APIResponse();

            try
            {
                DBResponse obj = new DBResponse();
                if (ModelState.IsValid)
                {
                    ContactDetails objContactDetails = new ContactDetails();
                    obj        = objContactDetails.SaveContact(objContact);
                    obj.Result = obj.ID > 0;
                    objResponse.StatusMessage = obj.Result ? "Thanks for your query. We will contact you soon." : AppMessage.SystemError;
                    objResponse.StatusCode    = obj.Result ? APIStatusCode.Success : APIStatusCode.InternalError;
                }
                else
                {
                    objResponse.StatusCode    = APIStatusCode.ValidationFailed;
                    objResponse.StatusMessage = "Please fill in all required fields";
                }
            }
            catch (Exception ex)
            {
                objResponse.StatusMessage = ex.Message;
                objResponse.StatusCode    = APIStatusCode.SystemError;
            }
            return(objResponse);
        }
Exemplo n.º 22
0
        public int UpdateContact(int ContactID, ContactEntity ContactEntity)
        {
            var success = 0;

            try
            {
                if (ContactEntity != null)
                {
                    Mapper.Initialize(cfg =>
                    {
                        cfg.CreateMap <ContactEntity, Contact>();
                    });

                    var Contact = Mapper.Map <ContactEntity, Contact>(ContactEntity);

                    _unitOfWork.ContactRepository.Update(Contact);
                    _unitOfWork.Save();
                    success = 1;
                }
            }
            catch (Exception)
            {
                //To Do add log code here
            }
            return(success);
        }
Exemplo n.º 23
0
        public Node <int> Search(ContactEntity GoalContact)
        {
            var Search = new AStarSearch <int>();
            var Root   = Adaptor();

            return(Search.Search(Root, ContactToNode(GoalContact)));
        }
Exemplo n.º 24
0
        public ActionResult EditContact(int id)
        {
            contact dbContact = pr.getById(id);

            ContactEntity contact = new ContactEntity();

            contact.City        = dbContact.City;
            contact.Comment     = dbContact.Comment;
            contact.CompanyID   = dbContact.CompanyID;
            contact.Country     = dbContact.Country;
            contact.DateOfBirth = dbContact.DateOfBirth;
            contact.emails      = dbContact.emails;
            contact.FirstName   = dbContact.FirstName;
            contact.LastName    = dbContact.LastName;
            contact.MiddleName  = dbContact.MiddleName;
            contact.Phone       = dbContact.Phone;
            contact.Photo       = dbContact.Photo;
            contact.Region      = dbContact.Region;
            contact.Sites       = dbContact.Sites;
            contact.State       = dbContact.State;
            contact.Street      = dbContact.Street;
            contact.Zip         = dbContact.Zip;

            return(View("ContactEditForm", contact));
        }
        public async T.Task OnGetAsync()
        {
            if (SearchId > 0)
            {
                var authenticationInfo = HttpContext.AuthenticateAsync()?.Result;
                if (authenticationInfo != null)
                {
                    // could use "User.Claims", but still need AuthInfo to access Tokens...

                    var webApiUrl      = authenticationInfo.Principal.Claims.Where(c => c.Type.Contains("webapi", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    var clientSettings = _superOfficeOptions.Get(SuperOfficeAuthenticationDefaults.AuthenticationScheme);
                    var callbackUri    = $"{this.Request.Scheme}://{this.Request.Host}{clientSettings.CallbackPath}";

                    var authorization = new AuthorizationAccessToken(
                        authenticationInfo.Properties.GetTokenValue(Constants.OAuth.AccessToken),
                        authenticationInfo.Properties.GetTokenValue(Constants.OAuth.IdToken),
                        authenticationInfo.Properties.GetTokenValue(Constants.OAuth.RefreshToken),
                        clientSettings.ClientId,
                        clientSettings.ClientSecret,
                        callbackUri,
                        GetEnvironment(clientSettings.Environment)
                        );

                    var config = new WebApiOptions(webApiUrl.Value, authorization);

                    ContactAgent ca = new ContactAgent(config);
                    ContactEntity = await ca.GetContactEntityAsync(SearchId);
                }
            }
        }
Exemplo n.º 26
0
        public ActionResult AddNewContact(ContactEntity contact)
        {
            if (!ModelState.IsValid)
            {
                return(View("ContactInsertForm", contact));
            }
            contact dbContact = new Models.contact();

            dbContact.City        = contact.City;
            dbContact.Comment     = contact.Comment;
            dbContact.CompanyID   = contact.CompanyID;
            dbContact.Country     = contact.Country;
            dbContact.DateOfBirth = contact.DateOfBirth;
            dbContact.emails      = contact.emails;
            dbContact.FirstName   = contact.FirstName;
            dbContact.LastName    = contact.LastName;
            dbContact.MiddleName  = contact.MiddleName;
            dbContact.Phone       = contact.Phone;
            dbContact.Photo       = contact.Photo;
            dbContact.Region      = contact.Region;
            dbContact.Sites       = contact.Sites;
            dbContact.State       = contact.State;
            dbContact.Street      = contact.Street;
            dbContact.Zip         = contact.Zip;

            pr.CreateNewContact(dbContact);
            return(RedirectToAction("Index", "Contact"));
        }
Exemplo n.º 27
0
        public void EditContact(ContactEntity contact)
        {
            if (contact == null)
            {
                return;
            }
            var dbContact = context.contacts.SingleOrDefault(c => c.id == contact.id);

            if (dbContact == null)
            {
                return;
            }
            dbContact.City        = contact.City;
            dbContact.Comment     = contact.Comment;
            dbContact.CompanyID   = contact.CompanyID;
            dbContact.Country     = contact.Country;
            dbContact.DateOfBirth = contact.DateOfBirth;
            dbContact.emails      = contact.emails;
            dbContact.FirstName   = contact.FirstName;
            dbContact.LastName    = contact.LastName;
            dbContact.MiddleName  = contact.MiddleName;
            dbContact.Phone       = contact.Phone;
            dbContact.Photo       = contact.Photo;
            dbContact.Region      = contact.Region;
            dbContact.Sites       = contact.Sites;
            dbContact.State       = contact.State;
            dbContact.Street      = contact.Street;
            dbContact.Zip         = contact.Zip;

            context.SaveChanges();
        }
Exemplo n.º 28
0
        public void TestMethod1()
        {
            ContactSqlDataProvider dataProvider  = CreateInstance(out IModelDataService <VContact> contactModelDataService, out IModelDataService <VEnquiry> enquiryModelDataService);
            ContactEntity          contactEntity = new ContactEntity();

            dataProvider.SaveContact(contactEntity);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Gets the data for the contact section in the home page.
        /// </summary>
        /// <returns>contact model containing the data for the contact section in the home page.</returns>
        public HomeEntity GetContactSectionData()
        {
            ContactEntity contactEntity = this.homeEntityFactory.GetContactEntity() as ContactEntity;

            contactEntity.Id   = "contact";
            contactEntity.Name = "Contact Me";
            List <FieldEntity> fields    = new List <FieldEntity>();
            FieldEntity        nameField = this.formEntityFactory.GetFieldEntity() as FieldEntity;

            nameField.Id                = "name";
            nameField.Name              = "Name";
            nameField.InputType         = "text";
            nameField.FieldType         = "input";
            nameField.PlaceHolder       = "Name";
            nameField.IsRequired        = true;
            nameField.ValidationMessage = "Please enter your name.";
            FieldEntity emailField = this.formEntityFactory.GetFieldEntity() as FieldEntity;

            emailField.Id                = "email";
            emailField.Name              = "Email Address";
            emailField.FieldType         = "input";
            emailField.InputType         = "email";
            emailField.PlaceHolder       = "Email Address";
            emailField.IsRequired        = true;
            emailField.ValidationMessage = "Please enter your email address.";
            FieldEntity phoneField = this.formEntityFactory.GetFieldEntity() as FieldEntity;

            phoneField.Id                = "phone";
            phoneField.Name              = "Phone Number";
            phoneField.FieldType         = "input";
            phoneField.InputType         = "tel";
            phoneField.PlaceHolder       = "Phone Number";
            phoneField.IsRequired        = true;
            phoneField.ValidationMessage = "Please enter your phone number.";
            FieldEntity messageField = this.formEntityFactory.GetFieldEntity() as FieldEntity;

            messageField.Id                = "message";
            messageField.Name              = "Message";
            messageField.FieldType         = "textarea";
            messageField.PlaceHolder       = "Message";
            messageField.IsRequired        = true;
            messageField.ValidationMessage = "Please enter a message.";
            fields.Add(nameField);
            fields.Add(emailField);
            fields.Add(phoneField);
            fields.Add(messageField);
            List <FormMetaEntity> formMetas   = new List <FormMetaEntity>();
            FormMetaEntity        rowFormMeta = this.formEntityFactory.GetFormMetaEntity() as FormMetaEntity;

            rowFormMeta.Type  = "row";
            rowFormMeta.Value = "5";
            formMetas.Add(rowFormMeta);
            messageField.FieldMetaList = formMetas;
            FormEntity contactFormEntity = this.formEntityFactory.GetFormEntity() as FormEntity;

            contactFormEntity.Fields  = fields;
            contactEntity.ContactForm = contactFormEntity;
            return(contactEntity);
        }
Exemplo n.º 30
0
        public ActionResult InsertContactHistory(ContactEntity entity)
        {
            System.Web.Http.HttpError errorHttp = null;

            if (entity == null)
            {
                errorHttp = new System.Web.Http.HttpError("ContactEntity is not found!");

                return(Ok(new Result
                {
                    Status = 404,
                    Message = errorHttp.Message,
                    Data = false
                }));
            }

            IDbContextTransaction transaction = _context.Database.BeginTransaction();

            try
            {
                // Open transaction.
                D_CONTACT contact = new D_CONTACT();

                contact.USER_RECIEVE_ID = entity.userRecieveId;
                contact.REG_MODE_USER   = entity.contactModeUser;
                contact.CONTACT_USER_ID = entity.contactUserId;
                contact.CATALOG_CD      = entity.catalogCd;
                contact.CONTACT_DATE    = Utility.GetSysDateTime();

                _context.D_CONTACTS.Add(contact);
                _context.SaveChanges();

                // Commit transaction.
                transaction.Commit();

                errorHttp = new System.Web.Http.HttpError("Insert is success!");

                return(Ok(new Result
                {
                    Status = 200,
                    Message = errorHttp.Message,
                    Data = true
                }));
            }
            catch
            {
                // Rollback transaction.
                transaction.Rollback();

                System.Web.Http.HttpError error = new System.Web.Http.HttpError("Error system!");

                return(Ok(new Result
                {
                    Status = 404,
                    Message = error.Message,
                    Data = false
                }));
            }
        }
Exemplo n.º 31
0
        internal static ContactEntity ExtractContact(IRoutingItem item)
        {
            ContactEntity contact = new ContactEntity();
            contact.EmailAddress = item.Content;
            if (item.Properties.ContainsKey(SMTPItemPropertyKeys.DisplayName))
            {
                contact.Alias = item.Properties[SMTPItemPropertyKeys.DisplayName];
            }
            contact.InternalContact = false;

            string emailAddress = contact.EmailAddress;

            if (emailAddress.Contains("@"))
            {
                contact.Alias = emailAddress.Substring(0, emailAddress.IndexOf("@"));
                contact.EmailDomain = emailAddress.Substring(emailAddress.IndexOf("@") + 1);
            }

            return contact;
        }