예제 #1
0
        // We need JobId and waypointId in order to put them in database columns for each Item.
        // This will make it organized for us to extract the approriate items for each Waypoint during the Get.
        public int SaveItem(WaypointItemPIckupRequest model, int?jobId, int waypointId)
        {
            int waypointItemId = 0;

            // This if statement assigns a default MediaId to an item that does not have an user image attached. The default MediaIds establish default stock images.
            if (model.MediaId == null && model.ItemTypeId > 0)
            {
                JobItemOptionsDomain JobItemOptions = _JobItemOptionsService.getIdJobItemOptions(model.ItemTypeId);
                model.MediaId = JobItemOptions.MediaId;
            }
            else
            {
                model.MediaId = model.MediaId;
            }

            if (model.Id == 0)                                                     // insert Item into database
            {
                _JobsWaypointService.WaypointItemInsert(model, jobId, waypointId); // this function returns waypointItemId
                return(waypointItemId);
            }
            else  // update Item in database
            {
                int wayPointItemId = 0;
                _JobsWaypointService.WaypointItemUpdate(model, jobId, waypointId);
                wayPointItemId = model.Id; // this line is needed because SaveItem() needs to return waypointItemId, so it can be added to a list of items in each waypoint
                return(wayPointItemId);
            }
        }
        public HttpResponseMessage getIdJobItemOptions(int id)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            JobItemOptionsDomain jobList = _OptionsService.getIdJobItemOptions(id);
            ItemResponse <JobItemOptionsDomain> response = new ItemResponse <JobItemOptionsDomain>();

            response.Item = jobList;
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }