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);
        }
        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;
        }
        public IHttpActionResult PostBusinessPhone(BusinessPhone businessPhone)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.CreateBusinessPhone(businessPhone);

            return CreatedAtRoute("DefaultApi", new { id = businessPhone.BusinessPhoneID }, businessPhone);
        }
        public void UpdateBusinessPhone(int id, BusinessPhone businessPhone)
        {
            db.Entry(businessPhone).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        /// <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;
        }
 /// <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);