Esempio n. 1
0
        public RequestForVisaDTO updateRequestForVisa(RequestForVisaDTO RequestForVisa)
        {
            var selectedRequestForVisa = uow.GetRepository <RequestForVisa>().Get(z => z.Id == RequestForVisa.Id);

            selectedRequestForVisa = MapperFactory.CurrentMapper.Map(RequestForVisa, selectedRequestForVisa);
            uow.GetRepository <RequestForVisa>().Update(selectedRequestForVisa);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <RequestForVisaDTO>(selectedRequestForVisa));
        }
        public HttpResponseMessage Get(int Id)
        {
            RequestForVisaDTO selectedTitle = service.getRequestForVisa(Id);

            if (selectedTitle == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle));
        }
        public HttpResponseMessage Put(RequestForVisaDTO RequestForVisaDTO)
        {
            RequestForVisaDTO dto = service.updateRequestForVisa(RequestForVisaDTO);

            if (dto != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dto));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title));
            }
        }
Esempio n. 4
0
 public RequestForVisaDTO newRequestForVisa(RequestForVisaDTO RequestForVisa)
 {
     if (!uow.GetRepository <RequestForVisa>().GetAll().Any(z => z.Id == RequestForVisa.Id))
     {
         var adedRequestForVisa = MapperFactory.CurrentMapper.Map <RequestForVisa>(RequestForVisa);
         adedRequestForVisa = uow.GetRepository <RequestForVisa>().Add(adedRequestForVisa);
         uow.SaveChanges();
         return(MapperFactory.CurrentMapper.Map <RequestForVisaDTO>(adedRequestForVisa));
     }
     else
     {
         return(null);
     }
 }
        public HttpResponseMessage Post(RequestForVisaDTO RequestForVisaDTO)
        {
            RequestForVisaDTO dto = service.newRequestForVisa(RequestForVisaDTO);

            if (dto != null)
            {
                HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, dto);
                message.Headers.Location = new Uri(Request.RequestUri + "/" + dto.Id);
                return(message);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.add_title));
            }
        }