public Response <bool> DeleteAsset(int assetId) { Response <bool> response = new Response <bool>(); try { AssetContext assetContext = new AssetContext(); var wasDeleted = assetContext.DeleteAsset(assetId); if (wasDeleted) { response.Item = true; response.Code = OperationCode.ResponseCode.SUCCESS; response.MessageList.Add(MessageResource.GetInstance().GetText("SawDAL_DeleteSuccess", MESSAGE_RESOURCE)); } else { response.Code = OperationCode.ResponseCode.ERROR; response.ErrorList.Add(MessageResource.GetInstance().GetText("SawDAL_DeleteInvalid", MESSAGE_RESOURCE)); } } catch (Exception ex) { response.Code = OperationCode.ResponseCode.ERROR; response.ErrorList.Add(MessageResource.GetInstance().GetText("SawDAL_DeleteInvalid", MESSAGE_RESOURCE)); } return(response); }
/// <summary> /// Get a specific Saw. /// </summary> /// <param name="id">Identifier for the Saw</param> /// <returns>Response with the operation status</returns> public Response <PersonDto> GetPerson(decimal id) { Response <PersonDto> response = new Response <PersonDto>(); // Look for the item indicated. Person result = ((0 < id) ? Person.Where(s => s.PersonId == id).FirstOrDefault() : null); if (result != null) { // Configure the success response. response.Item = new PersonDto() { PersonId = result.PersonId, Name = result.Name, LastName = result.LastName, Id = result.Id, Email = result.Email }; response.Code = OperationCode.ResponseCode.SUCCESS; response.MessageList.Add(MessageResource.GetInstance().GetText("PersonDAL_GetSuccess", MESSAGE_RESOURCE)); } else if (0 < id) { // Configure the Not Found response. response.Code = OperationCode.ResponseCode.NO_FOUND; response.NotFoundList.Add(MessageResource.GetInstance().GetText("PersonDAL_GetNotExisting", MESSAGE_RESOURCE)); } else { // Configure the Error response. response.Code = OperationCode.ResponseCode.ERROR; response.ErrorList.Add(MessageResource.GetInstance().GetText("PersonDAL_GetInvalid", MESSAGE_RESOURCE)); } return(response); }