コード例 #1
0
        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);
        }
コード例 #2
0
        public BusinessEmail Create(BusinessEmail oBusinessEmails)
        {
            if (oBusinessEmails != null)
            {
                return oBusinessEmailsRepos.CreateBusinessEmail(oBusinessEmails);
            }

            return null;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void UpdateBusinessEmail(int id, BusinessEmail businessEmail)
        {
            db.Entry(businessEmail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
 /// <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);
コード例 #7
0
 public BusinessEmail CreateBusinessEmail(BusinessEmail businessEmail)
 {
     db.BusinessEmails.Add(businessEmail);
     db.SaveChanges();
     return businessEmail;
 }