Esempio n. 1
0
        public async Task EditContact(string userID, int contactID, ContactsServiceModel model)
        {
            var contact = _context.contacts.Where(c => c.ID == contactID && c.userID == userID).FirstOrDefault();

            contact.firstName   = model.firstName;
            contact.lastName    = model.lastName;
            contact.numbertype  = model.numbertype;
            contact.Other       = model.Other;
            contact.Phonenumber = model.Phonenumber;
            contact.isfavorite  = model.isfavorite;
            contact.Adress      = model.adress;
            contact.City        = model.city;
            contact.Gender      = model.gender;
            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task <int> CreateContact(ContactsServiceModel model, string userID)
        {
            contact addModel = new()
            {
                userID      = userID,
                firstName   = model.firstName,
                lastName    = model.lastName,
                Gender      = model.gender,
                Phonenumber = model.Phonenumber,
                numbertype  = model.numbertype,
                City        = model.city,
                Adress      = model.adress,
                Other       = model.Other,
                isfavorite  = model.isfavorite,
            };

            _context.contacts.Add(addModel);
            await _context.SaveChangesAsync();


            return(addModel.ID);
        }
Esempio n. 3
0
 public async Task Edit(ContactsServiceModel model, int id)
 {
     await _service.EditContact(this.User.FindFirst(ClaimTypes.NameIdentifier).Value, id, model);
 }
Esempio n. 4
0
        public async Task <ActionResult> Create(ContactsServiceModel model)
        {
            var id = await _service.CreateContact(model, this.User.FindFirst(ClaimTypes.NameIdentifier).Value);

            return(Created(nameof(this.Create), id));
        }