Exemplo n.º 1
0
        /// <summary>
        /// Returns a particular approved object.
        /// </summary>
        /// <param name="id">Object's ID.</param>
        /// <returns>MapObjectViewModel object.</returns>
        public MapObjectViewModel Get(int id)
        {
            var findMapObject = Mapper
                                .Map <MapObjectDTO, MapObjectViewModel>(mapObjectService.GetMapObject(id));

            if (findMapObject.Status != Status.Approved)
            {
                return(null);
            }
            return(findMapObject);
        }
Exemplo n.º 2
0
 public IHttpActionResult Put(int id, [FromBody] MapObjectViewModel mapObject)
 {
     try
     {
         if (id == mapObject.Id)
         {
             // This is for confirmation by the administrator.
             // From the confirmation page comes the mapObject with the fields Id and Status.
             // We find the object in the database, load it, change its status and save it.
             if (mapObject.Status == Status.Approved)
             {
                 mapObject.TimeStamp = DateTime.Now;
                 mapObject           = Mapper
                                       .Map <MapObjectDTO, MapObjectViewModel>(mapObjectService.GetMapObject(id));
                 mapObject.Status = Status.Approved;
             }
             var approvedMapObject = Mapper
                                     .Map <MapObjectViewModel, MapObjectDTO>(mapObject);
             mapObjectService.UpdateMapObject(approvedMapObject);
             return(Ok());
         }
         return(BadRequest());
     }
     catch
     {
         return(BadRequest());
     }
 }