public IHttpActionResult PutBusinessEmail(int id, BusinessEmail businessEmail)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != businessEmail.BusinessEmailID)
            {
                return BadRequest();
            }

            db.Entry(businessEmail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessEmailExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public BusinessEmail Create(BusinessEmail oBusinessEmails)
        {
            if (oBusinessEmails != null)
            {
                return oBusinessEmailsRepos.CreateBusinessEmail(oBusinessEmails);
            }

            return null;
        }
        public IHttpActionResult PostBusinessEmail(BusinessEmail businessEmail)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.BusinessEmails.Add(businessEmail);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = businessEmail.BusinessEmailID }, businessEmail);
        }
        public void UpdateBusinessEmail(int id, BusinessEmail businessEmail)
        {
            db.Entry(businessEmail).State = EntityState.Modified;

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

            var entity = new BusinessEmail();

            entity.BusinessEmailID = dto.BusinessEmailID;
            entity.BusinessID = dto.BusinessID;
            entity.EmailID = dto.EmailID;
            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="BusinessEmail"/> converted from <see cref="BusinessEmailDTO"/>.</param>
 static partial void OnEntity(this BusinessEmailDTO dto, BusinessEmail entity);
 public BusinessEmail CreateBusinessEmail(BusinessEmail businessEmail)
 {
     db.BusinessEmails.Add(businessEmail);
     db.SaveChanges();
     return businessEmail;
 }