示例#1
0
        public async Task <IActionResult> Post([FromBody] AddContactModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(GetModelErrors(ModelState)));
            }
            try
            {
                var contact = new Contact
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Mobile    = model.Mobile,
                    Email     = model.Email,
                    Age       = model.Age,
                    TenantId  = this.TenantId
                };
                await _contactService.AddContactAsync(contact);

                return(Ok(model));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
示例#2
0
        public async Task AddContact(AddContactModel contact)
        {
            HttpResponseMessage response = await client.PostAsJsonAsync(
                "api/Contact/AddContact", contact);

            response.EnsureSuccessStatusCode();
        }
示例#3
0
 public void AddContact([FromBody] AddContactModel contact)
 {
     if (ModelState.IsValid)
     {
         contactService.AddContact(contact);
     }
 }
示例#4
0
        public IActionResult Update(UpdateContactModel InputContact4Update)
        {
            if (ModelState.IsValid && CheckFullNameWithTitleIsEmpty(InputContact4Update))
            {
                Contact Contact4Update = InputContact4Update.CreateContact();
                // if (ContactsRep.GetImageById(Contact4Update.Id) != Contact4Update.Image)
                // {
                if (InputContact4Update.Image != null && InputContact4Update.Image.Length > 0)
                {
                    using (var MemStream = new MemoryStream())
                    {
                        InputContact4Update.Image.CopyTo(MemStream);
                        Contact4Update.Image = MemStream.ToArray();
                    }
                }
                else
                {
                    Contact4Update.Image = ContactsRep.GetImageById(Contact4Update.Id);
                }
                // }
                //Types.DeattachTypes();
                ContactsRep.Update(Contact4Update);
                return(RedirectToAction());
            }
            AddContactModel model4disply = new AddContactModel();

            model4disply.Type4Display = Types.GetAll().ToList();
            model4disply.ContactItems = new List <AddContactItem>();
            model4disply.ContactItems.Add(new AddContactItem {
                Scope = true
            });
            return(View(model4disply));
        }
示例#5
0
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            DateTime birthDate;

            AddContactModel contact = new AddContactModel()
            {
                FisrtName = tbFirstName.Text,
                LastName  = tbLastName.Text
            };

            if (!string.IsNullOrEmpty(tbDateOfBirth.Text))
            {
                bool parseResult = DateTime.TryParse(tbDateOfBirth.Text, out birthDate);

                if (!parseResult)
                {
                    MessageBox.Show("Invalid birth date");
                    return;
                }

                contact.DateOfBirth = birthDate;
            }
            else
            {
                contact.DateOfBirth = null;
            }

            await webApiCommunication.AddContact(contact);
        }
示例#6
0
        public AddContactResponseViewModel AddContact(AddContactRequestViewModel request)
        {
            AddContactModel addContactModel = Mapper
                                              .Map <AddContactRequestViewModel, AddContactModel>(request);
            AddResultBaseModel <int> flag = new AddResultBaseModel <int>()
            {
                IsSuccessed = false,
                Id          = 0
            };

            using (var transaction = this.Context.Database.BeginTransaction())
            {
                try
                {
                    flag = _addContactServiceBll.Add(addContactModel);
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw;
                }
            }

            return(new AddContactResponseViewModel()
            {
                IsSuccessed = flag.IsSuccessed, ContactId = flag.Id
            });
        }
        //[ValidateAntiForgeryToken]
        public JsonResult SendContact([FromBody] AddContactModel contactModel)
        {
            if (ModelState.IsValid)
            {
                IConfigurationRoot configuration = new ConfigurationBuilder()
                                                   .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                                                   .AddJsonFile("appsettings.json")
                                                   .Build();

                using (var connObject = new SqlConnection(configuration.GetConnectionString("MsSQL")))
                {
                    string query = $"INSERT INTO ContactTable (Name,Email,Message,SendDate) VALUES('{contactModel.Name}','{contactModel.Email}','{contactModel.Message}','{DateTime.Now}') ";
                    try
                    {
                        connObject.Open();
                        connObject.Execute(query);
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { IsSuccess = false, Message = ex.Message + " \nQuery: " + query }));
                    }
                    finally
                    {
                        connObject.Close();
                    }
                }
                return(Json(new { IsSuccess = true, Message = contactModel.Language == "EN" ? "Your messsage has been successfully sent!" : "Mesajınız başarıyla gönderildi!" }));
            }
            else
            {
                return(Json(new { IsSuccess = false, Message = "Model hatalı! Lütfen boş alanları doldurunuz!" }));
            }
        }
        public async Task <AddContactResultModel> AddContact(AddContactModel model, string token)
        {
            var response = await _requestProvider
                           .PostAsync <AddContactModel, AddContactResultModel>(model, UrlAddress.AddContacts,
                                                                               token);

            return(response as AddContactResultModel);
        }
示例#9
0
        public AddResultBaseModel <int> Add(AddContactModel model)
        {
            string cName = model.Cname;
            string eName = string.Empty;

            if (model.Cname.Contains("/"))
            {
                eName = model.Cname;
                cName = string.Empty;
            }
            List <ContactInfoEntity> contactInfoEntities = _contactDal.Query <ContactInfoEntity>(
                n => n.Cid == model.Cid && n.IsDel == "F" && (n.Cname == model.Cname || n.Ename == model.Cname), true)
                                                           .ToList();

            if (contactInfoEntities != null && contactInfoEntities.Count > 0)
            {
                List <int> contactId = new List <int>();
                contactInfoEntities.ForEach(n => contactId.Add(n.Contactid));
                int count = _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                    n => contactId.Contains(n.Contactid) && n.CardNo == model.CardNo, true).Count();
                if (count > 0)
                {
                    throw new Exception("当前已经存在该信息");
                }
            }


            ContactInfoEntity contactInfo = new ContactInfoEntity()
            {
                Cname          = cName,
                Ename          = eName,
                Mobile         = model.Mobile,
                Cid            = model.Cid,
                LastUpdateTime = DateTime.Now,
                IsDel          = "F",
                IsPassenger    = model.IsPassenger,
                UpdateOid      = "sys",
                DelTime        = DateTime.Now,
                Email          = model.Email,
                IsOnline       = (model.OrderSource == "O" ? 0 : 1)
            };

            contactInfo = _contactDal.Insert <ContactInfoEntity>(contactInfo);

            _contactIdentificationDal.Insert <ContactIdentificationInfoEntity>(new ContactIdentificationInfoEntity()
            {
                Contactid      = contactInfo.Contactid,
                CardNo         = model.CardNo,
                Iid            = model.Iid,
                LastUpdateTime = DateTime.Now
            });

            return(new AddResultBaseModel <int>()
            {
                IsSuccessed = true,
                Id = contactInfo.Contactid
            });
        }
        public string SerializerDataAddContact(string email)
        {
            var    dataContact = new AddContactModel();
            string resultado   = string.Empty;

            dataContact.emails = new List <string>();
            dataContact.emails.Add(email.Replace("400", ""));
            return(JsonConvert.SerializeObject(dataContact));
        }
示例#11
0
        public IActionResult Add()
        {
            AddContactModel model = new AddContactModel();

            model.Type4Display = Types.GetAll().ToList();
            model.ContactItems = new List <AddContactItem>();
            model.ContactItems.Add(new AddContactItem {
                Scope = true
            });
            return(View(model));
        }
        public async Task <IActionResult> Create([FromBody] AddContactModel item)
        {
            var result = _contactValidator.Validate(item);

            if (result.IsValid)
            {
                int itemId = await _contactService.CreateAsync(item);

                return(CreatedAtAction(nameof(Get), new { id = itemId }, item));
            }
            else
            {
                return(BadRequest(result.Errors.Select(t => t.ErrorMessage)));
            }
        }
示例#13
0
        public async Task <IActionResult> AddContact([FromBody] AddContactModel model)
        {
            await _contactService.AddContact(new Contact
            {
                Surname      = model.Surname,
                Name         = model.Name,
                Patronymic   = model.Patronymic,
                Organization = model.Organization,
                Position     = model.Position,
                Email        = model.Email,
                Phone        = model.Phone,
                User         = model.User
            });

            return(Ok());
        }
示例#14
0
        private Guid?AddUserAsAContact(UserDB user)
        {
            string ownerMail;

            if (!_configService.Custom.TryGetValue("salesmanago_owner_mail", out ownerMail) ||
                string.IsNullOrWhiteSpace(ownerMail))
            {
                return(null);
            }

            var client  = new RestClient(BaseUrl);
            var request = new RestRequest(@"/contact/insert", Method.POST);
            var body    = new AddContactModel
            {
                owner   = ownerMail,
                lang    = user.Locale,
                tags    = GetUserTags(user),
                contact = new ContactModel
                {
                    name  = string.Format("{0} {1}", user.UserName, user.UserSurname),
                    phone = user.UserPhone,
                    email = user.UserEmail,
                    state = "CUSTOMER"
                }
            };

            if (!TryInitializeRequestData(body))
            {
                return(null);
            }


            request.AddJsonBody(body);
            var response = client.Execute <dynamic>(request);

            if (response.Data["success"] != true)
            {
                return(null);
            }

            return(Guid.Parse(response.Data["contactId"]));
        }
示例#15
0
        public IActionResult Add(AddContactModel InputContact)
        {
            if (ModelState.IsValid && CheckFullNameWithTitleIsEmpty(InputContact))
            {
                Contact Contact4Add = new Contact {
                    FirstName    = InputContact.FirstName,
                    LastName     = InputContact.LastName,
                    Title        = InputContact.Title,
                    Note         = InputContact.Note,
                    ContactItems = new List <ContactItem>(InputContact.ContactItems.Select(ci => new ContactItem
                    {
                        Value    = ci.Value,
                        Scope    = ci.Scope,
                        ItemType = Types.FindById(ci.TypeId)
                    }))
                };
                if (InputContact.Image != null && InputContact.Image.Length > 0)
                {
                    using (var MemStream = new MemoryStream())
                    {
                        InputContact.Image.CopyTo(MemStream);
                        Contact4Add.Image = MemStream.ToArray();
                    }
                }
                ContactsRep.Add(Contact4Add);
                return(RedirectToAction());
            }
            AddContactModel model4disply = new AddContactModel();

            model4disply.Type4Display = Types.GetAll().ToList();
            model4disply.ContactItems = new List <AddContactItem>();
            model4disply.ContactItems.Add(new AddContactItem {
                Scope = true
            });
            return(View(model4disply));
        }
示例#16
0
        public void AddContact(AddContactModel model)
        {
            var emails = model.EmailAddresses.Select(x => new Email()
            {
                Adreess = x.Address,
            }).ToList();

            var phones = model.PhoneNumbers.Select(x => new Phone()
            {
                Number = x.Number,
            }).ToList();

            var contact = new Contact()
            {
                FirstName   = model.FisrtName,
                LastName    = model.LastName,
                DateOfBirth = model.DateOfBirth,
                Phones      = phones,
                Emails      = emails
            };

            context.Contacts.Add(contact);
            context.SaveChanges();
        }
示例#17
0
        public MainPage()
        {
            InitializeComponent();

            BindingContext = new AddContactModel();
        }
        public async Task <int> CreateAsync(AddContactModel item)
        {
            var contact = _mapper.Map <ContactModel, Contact>(item);

            return(await _contactRepository.CreateContactAsync(contact));
        }
示例#19
0
 private bool CheckFullNameWithTitleIsEmpty(AddContactModel Contact4Check)
 {
     return(!(string.IsNullOrEmpty(Contact4Check.FirstName) &&
              string.IsNullOrEmpty(Contact4Check.LastName) &&
              string.IsNullOrEmpty(Contact4Check.Title)));
 }