public IHttpActionResult PutUserEmail(int id, UserEmail userEmail)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != userEmail.UserEmailID)
            {
                return BadRequest();
            }

            try
            {
                db.UpdateUserEmail(id, userEmail);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserEmailExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
        public UserEmail CreateUserEmail(UserEmail userEmail)
        {
            db.UserEmails.Add(userEmail);
            db.SaveChanges();

            return userEmail;
        }
Пример #3
0
        public UserEmail Create(UserEmail oUserEmail)
        {
            if (oUserEmail != null)
            {
                return oUserEmailRepo.CreateUserEmail(oUserEmail);
            }

            return null;
        }
        public IHttpActionResult PostUserEmail(UserEmail userEmail)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.CreateUserEmail(userEmail);

            return CreatedAtRoute("DefaultApi", new { id = userEmail.UserEmailID }, userEmail);
        }
Пример #5
0
        public void UpdateUserEmail(int id, UserEmail userEmail)
        {
            db.Entry(userEmail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Пример #6
0
        /// <summary>
        /// Converts this instance of <see cref="UserEmailDTO"/> to an instance of <see cref="UserEmail"/>.
        /// </summary>
        /// <param name="dto"><see cref="UserEmailDTO"/> to convert.</param>
        public static UserEmail ToEntity(this UserEmailDTO dto)
        {
            if (dto == null) return null;

            var entity = new UserEmail();

            entity.UserEmailID = dto.UserEmailID;
            entity.UserID = dto.UserID;
            entity.EmailID = dto.EmailID;
            entity.IsPrimary = dto.IsPrimary;

            dto.OnEntity(entity);

            return entity;
        }
Пример #7
0
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="UserEmail"/> converted from <see cref="UserEmailDTO"/>.</param>
 static partial void OnEntity(this UserEmailDTO dto, UserEmail entity);