Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> UpdatePredmet(PredmetiViewModel updateP)
        {
            try
            {
                PredmetiViewModel toBeUpdated = Mapper.Map <PredmetiViewModel>(await PredmetiService.Get(updateP.PredmetiId));

                if (toBeUpdated == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Nije pronađen traženi predmet."));
                }
                if (updateP.Ime_predmeta == null || updateP.PredmetiId == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Greška u unosu!"));
                }
                else
                {
                    toBeUpdated.Ime_predmeta = updateP.Ime_predmeta;
                }
                var response = await PredmetiService.Update(Mapper.Map <IPredmetiDomainModel>(toBeUpdated));

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
Ejemplo n.º 2
0
 public PredmetiView()
 {
     try
     {
         vm = new PredmetiViewModel();
         this.InitializeComponent();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> AddPredmet(PredmetiViewModel addObj)
        {
            try
            {
                addObj.PredmetiId = Guid.NewGuid();
                var response = await PredmetiService.Add(Mapper.Map <IPredmetiDomainModel>(addObj));

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
Ejemplo n.º 4
0
 public PredmetiPage(int Klijent)
 {
     InitializeComponent();
     KlijentId      = Klijent;
     BindingContext = model = new PredmetiViewModel(KlijentId);
 }