コード例 #1
0
        public IHttpActionResult PutBusinessPhone(int id, BusinessPhone businessPhone)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != businessPhone.BusinessPhoneID)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public BusinessPhone CreateBusinessPhone(BusinessPhone businessPhone)
        {
            db.BusinessPhones.Add(businessPhone);
            db.SaveChanges();

            return businessPhone;
        }
コード例 #3
0
        public BusinessPhone Create(BusinessPhone oBusinessPhone)
        {
            if (oBusinessPhone != null)
            {
                return oBusinessPhoneRepos.CreateBusinessPhone(oBusinessPhone);
            }

            return null;
        }
コード例 #4
0
        public IHttpActionResult PostBusinessPhone(BusinessPhone businessPhone)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.CreateBusinessPhone(businessPhone);

            return CreatedAtRoute("DefaultApi", new { id = businessPhone.BusinessPhoneID }, businessPhone);
        }
コード例 #5
0
        public void UpdateBusinessPhone(int id, BusinessPhone businessPhone)
        {
            db.Entry(businessPhone).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
コード例 #6
0
        /// <summary>
        /// Converts this instance of <see cref="BusinessPhoneDTO"/> to an instance of <see cref="BusinessPhone"/>.
        /// </summary>
        /// <param name="dto"><see cref="BusinessPhoneDTO"/> to convert.</param>
        public static BusinessPhone ToEntity(this BusinessPhoneDTO dto)
        {
            if (dto == null) return null;

            var entity = new BusinessPhone();

            entity.BusinessPhoneID = dto.BusinessPhoneID;
            entity.BusinessID = dto.BusinessID;
            entity.PhoneID = dto.PhoneID;
            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="BusinessPhone"/> converted from <see cref="BusinessPhoneDTO"/>.</param>
 static partial void OnEntity(this BusinessPhoneDTO dto, BusinessPhone entity);