Пример #1
0
        /// <summary>
        /// udostępniona metoda aktyalizacji danych o łódce
        /// </summary>
        /// <param name="boatRequest"></param>
        /// <returns>zwracana odpowiedź czy udalo się zaktualizować dane</returns>
        public BaseResponse UpdateBoat(BoatRequest boatRequest)
        {
            var response = new BaseResponse();

            try
            {
                _unitOfWork.BeginTransaction();
                var check = _repositoryBoat.GetGuidBoat(boatRequest.Model, boatRequest.Name);
                if (check != Guid.Empty)
                {
                    Boat boat = Mapper.Map <Boat>(boatRequest);
                    _repositoryBoat.Update(boat);
                    _unitOfWork.Commit();
                    response.IsSuccess = true;
                }
                else
                {
                    _unitOfWork.Commit();
                    response.IsSuccess    = false;
                    response.ErrorMessage = "Łódka o takiej nazwie i modelu nie istnieje";
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess    = false;
                response.ErrorMessage = ex.ToString();
            }
            return(response);
        }
 /// <summary>
 /// udostępniona metoda dodania łódki do bazy
 /// </summary>
 /// <param name="boatRequest"></param>
 /// <returns>zwracana odpowiedź czy udało się dodać lódkę do bazy
 /// </returns>
 public BaseResponse AddBoat(BoatRequest boatRequest)
 {
     var response = new BaseResponse();
     try
     {
         _unitOfWork.BeginTransaction();
         var check = _repositoryBoat.GetGuidBoat(boatRequest.Model, boatRequest.Name);
         if (check == Guid.Empty)
         {
             Boat boat = Mapper.Map<Boat>(boatRequest);
             boat.IdBoat=Guid.NewGuid();
             _repositoryBoat.Add(boat);
             _unitOfWork.Commit();
             response.IsSuccess = true;
         }
         else
         {
             _unitOfWork.Commit();
             response.IsSuccess = false;
             response.ErrorMessage = "Łódka o takiej nazwie i modelu juz istnieje";
         }
     }
     catch (Exception ex)
     {
         response.IsSuccess = false;
         response.ErrorMessage = ex.ToString();
     }
     return response;
 }
Пример #3
0
        /// <summary>
        /// udostępniona metoda pobierania Id łódki
        /// </summary>
        /// <param name="boatRequest"></param>
        /// <returns>zwracana odpowiedź czy udało się pobrać Id</returns>
        public GetBoatResponse GetBoatId(BoatRequest boatRequest)
        {
            var response = new GetBoatResponse();

            try
            {
                _unitOfWork.BeginTransaction();
                var check = _repositoryBoat.GetGuidBoat(boatRequest.Model, boatRequest.Name);
                if (check != Guid.Empty)
                {
                    response.Id = check;
                    _unitOfWork.Commit();
                    response.IsSuccess = true;
                }
                else
                {
                    _unitOfWork.Commit();
                    response.IsSuccess    = false;
                    response.ErrorMessage = "Nie istnieje łódki o takim id";
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess    = false;
                response.ErrorMessage = ex.ToString();
            }
            return(response);
        }
 /// <summary>
 /// udostępniona metoda pobierania Id łódki
 /// </summary>
 /// <param name="boatRequest"></param>
 /// <returns>zwracana odpowiedź czy udało się pobrać Id</returns>
 public GetBoatResponse GetBoatId(BoatRequest boatRequest)
 {
     var response = new GetBoatResponse();
     try
     {
         _unitOfWork.BeginTransaction();
         var check = _repositoryBoat.GetGuidBoat(boatRequest.Model, boatRequest.Name);
         if (check != Guid.Empty)
         {
             response.Id = check;
             _unitOfWork.Commit();
             response.IsSuccess = true;
         }
         else
         {
             _unitOfWork.Commit();
             response.IsSuccess = false;
             response.ErrorMessage = "Nie istnieje łódki o takim id";
         }
     }
     catch (Exception ex)
     {
         response.IsSuccess = false;
         response.ErrorMessage = ex.ToString();
     }
     return response;
 }