public IHttpActionResult PutBusiness(int id, Business business)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != business.BusinessID)
            {
                return BadRequest();
            }

            try
            {
                _business.UpdateBusiness(business);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public Business CreateBusiness(Business business)
        {
            db.Businesses.Add(business);
            db.SaveChanges();

            return business;
        }
示例#3
0
        public Business Create(Business oBusiness)
        {
            if (oBusiness != null)
            {
                return oBusinessRepo.CreateBusiness(oBusiness);
            }

            return null;
        }
        public IHttpActionResult PostBusiness(Business business)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            _business.CreateBusiness(business);

            return CreatedAtRoute("DefaultApi", new { id = business.BusinessID }, business);
        }
        public void UpdateBusiness(int id, Business business)
        {
            db.Entry(business).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
示例#6
0
        public Business CreateBusiness(Business oBusiness)
        {
            Business oBusinessReturn = null;

            using (DBContext)
            {
                try
                {
                    oBusinessReturn = DBContext.Businesses.Add(oBusiness);
                    DBContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    //Log Exception.
                }
            }

            return oBusinessReturn;
        }
示例#7
0
        public Business UpdateBusiness(Business oBusiness)
        {
            Business oBusinessReturn = null;
            if (oBusiness != null && oBusiness.BusinessID > 0)
            {
                using (DBContext)
                {
                    Business u = this.GetBusinessByID(oBusiness.BusinessID);

                    if (u != null)
                    {
                        Mapper.Map<Business, Business>(oBusiness, u);
                        DBContext.SaveChanges();
                        oBusinessReturn = u;
                    }
                }
            }

            return oBusinessReturn;
        }
示例#8
0
        /// <summary>
        /// Converts this instance of <see cref="BusinessDTO"/> to an instance of <see cref="Business"/>.
        /// </summary>
        /// <param name="dto"><see cref="BusinessDTO"/> to convert.</param>
        public static Business ToEntity(this BusinessDTO dto)
        {
            if (dto == null) return null;

            var entity = new Business();

            entity.BusinessID = dto.BusinessID;
            entity.Name = dto.Name;
            entity.Abbreviation = dto.Abbreviation;
            entity.StartDate = dto.StartDate;
            entity.BusinessTypeID = dto.BusinessTypeID;
            entity.IsActive = dto.IsActive;
            entity.IsDeleted = dto.IsDeleted;
            entity.insuser = dto.insuser;
            entity.insdt = dto.insdt;
            entity.upduser = dto.upduser;
            entity.upddt = dto.upddt;

            dto.OnEntity(entity);

            return entity;
        }
示例#9
0
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="Business"/> converted from <see cref="BusinessDTO"/>.</param>
 static partial void OnEntity(this BusinessDTO dto, Business entity);