Beispiel #1
0
 public HttpResponseMessage UpdateHardware(int id, Hardware hardware)
 {
     try
     {
         if (_hardwareRepository.Update(id, hardware))
         {
             HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
             return(response);
         }
         else
         {
             HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotModified);
             return(response);
         }
     }
     catch (Exception) {
         HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
         return(response);
     }
 }
Beispiel #2
0
        /// <summary>
        /// The Save
        /// </summary>
        /// <param name="entity">The entity<see cref="Hardware"/></param>
        /// <returns>The <see cref="ServiceResult"/></returns>
        public ServiceResult Save(Hardware entity)
        {
            try
            {
                if (entity.Identifier == 0)
                {
                    _repository.Add(entity);
                }
                else
                {
                    _repository.Update(entity);
                }

                return(new ServiceResult(true));
            }
            catch (Exception ex)
            {
                return(new ServiceResult(false)
                {
                    Error = ex.ToString()
                });
            }
        }
Beispiel #3
0
        public IHttpActionResult PutHardware(int id, HardwareDto hardwareDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var hardware = GetHardware(id);

            if (hardware == null)
            {
                return(NotFound());
            }

            if (id != hardwareDto.Id)
            {
                return(BadRequest());
            }

            var hardwareDb = _repository.Update(MapBackToModel(hardwareDto));

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void Update(Hardware hardware)
 {
     repository.Update(hardware);
 }