Beispiel #1
0
 public void AddContact([FromBody] AddContactModel contact)
 {
     if (ModelState.IsValid)
     {
         contactService.AddContact(contact);
     }
 }
Beispiel #2
0
        public async Task <ActionResult> AddContacts(ContactViewModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BadRequest("contact model is empty"));
                }

                var contact = _mapper.Map <Contact>(model);

                var modelExists = await _contactService.CheckContactExist(contact);

                if (modelExists == false)
                {
                    _contactService.AddContact(contact);
                }
                else
                {
                    return(Conflict("Contact Number alreadly exists"));
                }
                return(Ok("User has been loaded successfully"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task AddContact_Should_Return_Error_When_FirstNameIsEmpty()
        {
            //Arrange
            ContactRequest request = new ContactRequest();

            try
            {
                //Act
                var result = await constactService.AddContact(request);
            }
            catch (Exception ex)
            {
                //Test
                Assert.IsNotNull(ex.Message);
            }
        }
Beispiel #4
0
        public IActionResult AddNewContact([FromBody] Contact contact)
        {
            GenericResult _result = new GenericResult();

            try
            {
                var result = _contactService.AddContact(contact);
                if (result == true)
                {
                    return(Json(new { result = result, Message = "Contact added successfully" }));
                }
                else
                {
                    throw new Exception("There was a problem adding the contact");
                }
            }
            catch (Exception ex)
            {
                _result = new GenericResult()
                {
                    Succeeded = false,
                    Message   = ex.Message
                };

                _logger.LogFatal(ex);
                return(Json(_result));
            }
        }
Beispiel #5
0
        public ActionResult Create_contact([DataSourceRequest] DataSourceRequest request, ContactViewModel contact)
        {
            if (contact != null && ModelState.IsValid)
            {
                try
                {
                    var c = new Contact()
                    {
                        FDPID     = contact.FDPID,
                        FirstName = contact.FirstName,
                        LastName  = contact.LastName,
                        PhoneNo   = contact.PhoneNo,
                    };

                    _contactService.AddContact(c);
                    return(RedirectToAction("Index", "FDP"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Errors", @"Check");
                }
            }
            return(RedirectToAction("Index", "FDP"));
            //return Json(new[] { contact }.ToDataSourceResult(request, ModelState));
        }
Beispiel #6
0
        private async Task Subscribe_ContactDetail_Add(ContactDetailPage page, ContactDetailPageViewModel viewModel)
        {
            SelectedContact         = null;
            viewModel.ContactAdded += async(source, args) =>
            {
                bool isAdd = args.Id == 0;
                if (isAdd)
                {
                    Contacts.Add(args);
                    await _contactService.AddContact(args);
                }
                else
                {
                    var existingContact = Contacts.Where(x => x.Id == args.Id).FirstOrDefault();
                    Contacts[Contacts.IndexOf(existingContact)] = args;
                    await _contactService.UpdateContact(args);
                }
                await _pageService.DisplayAlert("Add Contact",
                                                string.Format("Contact has been {0}", (isAdd) ? "added" : "modified"),
                                                "OK");

                await _pageService.PopAsync();
            };

            await _pageService.PushAsync(page);
        }
        //Create contact
        public HttpResponseMessage Post(ContactServiceModel contact)
        {
            GetRequestConfig();
            Person person       = contact.MapToEntity();
            var    addedContact = _contactsService.AddContact(person);

            return(Request.CreateResponse(HttpStatusCode.Created, addedContact));
        }
Beispiel #8
0
        public IActionResult AddContact(List <Registration_ContactPerson> model)
        {
            model[0].ContactTypeID = 1;
            model[1].ContactTypeID = 2;

            _contactService.AddContact(model);
            return(Json(true));
        }
Beispiel #9
0
        public ActionResult AddContact(ContactModel contact)
        {
            int userId = GetAuthorizedUserId();

            _contactService.AddContact(contact, userId);

            return(Ok());
        }
Beispiel #10
0
        public void AddContact([FromBody] ContactViewModel contact)
        {
            var userName     = User.Identity.Name;
            var userId       = _UserService.GetUserIdByName(userName);
            var contactModel = Mapper.Map <ContactBusinessModel>(contact);

            contactModel.CreatedByUserId = userId;
            _contactService.AddContact(contactModel);
        }
 public IActionResult Create([Bind("Id,Name,PhoneNumber,HomePhone")] Entities.Contact contact)
 {
     if (ModelState.IsValid)
     {
         _contactService.AddContact(contact);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(contact));
 }
 public IActionResult AddContact([FromBody] Contact contact)
 {
     int.TryParse(User.Identity.Name, out int userId);
     contact.OwnerId = userId;
     if (_contactService.AddContact(contact))
     {
         return(Ok(contact));
     }
     return(BadRequest("There is something wrong with contact info"));
 }
        public ActionResult AddContact(Contact con)
        {
            if (ModelState.IsValid)
            {
                ModelState.Clear();
                _iContactService.AddContact(con);
            }

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create([Bind("Name,Surname,TellNumber,Email,Number")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                await _contactService.AddContact(contact);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
Beispiel #15
0
        public IActionResult AddContact([FromBody] Contact contact)
        {
            var contacts = _contactService.AddContact(contact);

            if (!contacts)
            {
                return(Problem("Resource is already exists!", "", 409));
            }
            return(Ok(contacts));
        }
 public async Task <IActionResult> Add(ContactRequest contact)
 {
     try
     {
         return(Ok(await _contactService.AddContact(contact)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
 }
Beispiel #17
0
 public object SaveContact(Contact model)
 {
     try
     {
         return(new { Status = ContactService.AddContact(model) });
     }
     catch (Exception ex)
     {
         return(new { Status = false, erros = returnError(ex) });
     }
 }
Beispiel #18
0
 public ActionResult Create(Contact contact)
 {
     if (ModelState.IsValid)
     {
         _contactService.AddContact(contact);
         return(RedirectToAction("Index", new { fdpId = contact.FDPID }));
     }
     ViewBag.FDPName = _contactService.FindById(contact.ContactID).FDP.Name;
     ViewBag.FDPID   = contact.FDPID;
     return(View("Create", contact));
 }
Beispiel #19
0
 public IActionResult AddContact([FromBody] Contact contact)
 {
     try
     {
         var response = _contactService.AddContact(contact);
         return(Ok(response));
     }
     catch (Exception exception)
     {
         return(BadRequest(exception.Message));
     }
 }
Beispiel #20
0
        public ActionResult Contact(ContactModel contact)
        {
            if (!ModelState.IsValid)
            {
                return(View(contact));
            }

            contact.UserId = User.Identity.GetUserId();

            contactService.AddContact(contact);

            return(RedirectToAction("Index", new { pageNo = 1, pageSize = 10 }));
        }
 public IActionResult AddContact(Contact contact)
 {
     ViewBag.list = ContactList.GetAllContacts();
     if (ModelState.IsValid)
     {
         var getId = ContactList.AddContact(contact);
         return(RedirectToAction("Details", new { id = getId }));
     }
     else
     {
         return(View("Add"));
     }
 }
 public IActionResult AddContact(ContactRegisterModel model)
 {
     if (ModelState.IsValid)
     {
         var result = new Contacts()
         {
             ContactMobile = model.ContactMobile, ContactName = model.ContactName, UserId = _userManager.GetUserId(User)
         };
         contactService.AddContact(result);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Beispiel #23
0
 public ActionResult Create(ContactViewModel model)
 {
     if (ModelState.IsValid)
     {
         int id = _contactService.AddContact(new Contact()
         {
             FirstName = model.FirstName,
             LastName  = model.LastName,
             Email     = model.Email
         });
         return(Json(new { Success = true, Object = id }, JsonRequestBehavior.AllowGet));
     }
     return(PartialView("_Create", model));
 }
        public async Task <AddContactsResponse> AddContacts([FromBody] List <ContactViewModel> mContact)
        {
            _logger.LogInformation("Add contact list from method AddContacts()");
            var eContact = AutoMapConverter.ConvertObjectCollection <ContactViewModel, Contact>(mContact);
            var result   = await _contactServiceAgent.AddContact(eContact);

            var addContactResponse = new Models.AddContactsResponse()
            {
                ContactIdList = result
            };

            _logger.LogInformation($"Add contact list from method AddContacts() successful with count : {addContactResponse?.ContactIdList.Count}");
            return(addContactResponse);
        }
Beispiel #25
0
        public JsonResult SendContact(Contact info)
        {
            string Mess = "error";

            if (info != null)
            {
                // add/update
                if (_contactService.AddContact(info))
                {
                    Mess = "success";
                }
            }

            return(Json(Mess));
        }
Beispiel #26
0
        protected void btnSent_Click(object sender, EventArgs e)
        {
            var name    = FullName.Text.ToString();
            var address = Address.Text.ToString();
            var email   = Email.Text.ToString();
            var phone   = Phone.Text.ToString();
            var opinion = Opinion.Text.ToString();

            if (name.StringIsNullEmptyWhiteSpace())
            {
                Notification.Text = "Please input full name";
            }
            else if (address.StringIsNullEmptyWhiteSpace())
            {
                Notification.Text = "Please input address";
            }
            else if (email.StringIsNullEmptyWhiteSpace())
            {
                Notification.Text = "Please input email";
            }
            else if (phone.StringIsNullEmptyWhiteSpace())
            {
                Notification.Text = "Please input phone";
            }
            else if (opinion.StringIsNullEmptyWhiteSpace())
            {
                Notification.Text = "Please input opinion";
            }
            else
            {
                var contact = new WebFormLogin.DataAccess.Models.Contact();
                contact.FullName = name;
                contact.Address  = address;
                contact.Email    = email;
                contact.Phone    = phone;
                contact.Opinion  = opinion;
                var model = contactService.AddContact(contact);
                if (model.IsNull())
                {
                    Notification.Text = "Please try again";
                }
                else
                {
                    NotificationSuccess.Text = "Sent success";
                    ClearFields(Form.Controls);
                }
            }
        }
Beispiel #27
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());
        }
        public async Task <IHttpActionResult> AddContact([FromBody] ContactDto contact)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                return(Ok(await _contactService.AddContact(contact)));
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }
        }
        public IActionResult Modify(ContactModel model)
        {
            // Validate model here


            if (!model.IsEdit)
            {
                _contactService.AddContact(model.ToEntity());
            }
            else
            {
                _contactService.UpdateContact(model.ToEntity());
            }

            return(RedirectTo(Constant.ListController));
        }
Beispiel #30
0
        public async Task <IActionResult> Add(string id)
        {
            string Id         = User.Claims.First(c => c.Type == "Id").Value;
            bool   hasContact = contactService.HasContact(Id, id);

            if (hasContact)
            {
                return(BadRequest());
            }
            else
            {
                var contact = await contactService.AddContact(Id, id);

                return(Ok(contact));
            }
        }