public IHttpActionResult PutUserPhone(int id, UserPhone userPhone)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != userPhone.UserPhoneID)
            {
                return BadRequest();
            }

            try
            {
                db.UpdateUserPhone(id, userPhone);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserPhoneExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Esempio n. 2
0
        public UserPhone CreateUserPhone(UserPhone userPhone)
        {
            db.UserPhones.Add(userPhone);
            db.SaveChanges();

            return userPhone;
        }
Esempio n. 3
0
        public UserPhone Create(UserPhone oUserPhone)
        {
            if (oUserPhone != null)
            {
                return oUserPhoneRepo.CreateUserPhone(oUserPhone);
            }

            return null;
        }
        public IHttpActionResult PostUserPhone(UserPhone userPhone)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.CreateUserPhone(userPhone);

            return CreatedAtRoute("DefaultApi", new { id = userPhone.UserPhoneID }, userPhone);
        }
Esempio n. 5
0
        public void UpdateUserPhone(int id, UserPhone userPhone)
        {
            db.Entry(userPhone).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        /// <summary>
        /// Converts this instance of <see cref="UserPhoneDTO"/> to an instance of <see cref="UserPhone"/>.
        /// </summary>
        /// <param name="dto"><see cref="UserPhoneDTO"/> to convert.</param>
        public static UserPhone ToEntity(this UserPhoneDTO dto)
        {
            if (dto == null) return null;

            var entity = new UserPhone();

            entity.UserPhoneID = dto.UserPhoneID;
            entity.UserID = dto.UserID;
            entity.PhoneID = dto.PhoneID;
            entity.IsPrimary = dto.IsPrimary;

            dto.OnEntity(entity);

            return entity;
        }
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="UserPhone"/> converted from <see cref="UserPhoneDTO"/>.</param>
 static partial void OnEntity(this UserPhoneDTO dto, UserPhone entity);