Exemple #1
0
        public IHttpActionResult PutKorisnici(int id, Administrator_SelectOne a)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != a.AdministratorId)
            {
                return(BadRequest());
            }

            try
            {
                db.tsp_Administrator_Update(a.AdministratorId, a.Ime, a.Prezime, a.Email, a.Telefon, a.KorisnickoIme, a.LozinkaHash, a.LozinkaSalt);
            }
            catch (EntityCommandExecutionException ex)
            {
                var          nesto  = ex.GetType().ToString();
                SqlException greska = ex.InnerException as SqlException;
                if (greska != null)
                {
                    return(BadRequest(Util.ExceptionHandler.DbUpdateExceptionHandler(greska)));
                }
            }



            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult GetAdministrator(int id)
        {
            Administrator_SelectOne admin = db.tsp_Administrator_SelectOne(id).FirstOrDefault();

            if (admin == null)
            {
                return(NotFound());
            }

            return(Ok(admin));
        }
        public EditAdministrator(int administratorId)
        {
            InitializeComponent();
            this.AutoValidate = AutoValidate.Disable;

            HttpResponseMessage response = administratorService.GetResponse(administratorId.ToString());

            if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                admin = null;
            }
            else if (response.IsSuccessStatusCode)
            {
                admin = response.Content.ReadAsAsync <Administrator_SelectOne>().Result;
                FillForm();
            }
        }