예제 #1
0
        //POST: criar uma sala

        /* Coordenadas e Limites de Musicas/Horas sao opcionais
         */
        public HttpResponseMessage PostCriar(SalaCriacaoModel model)
        {
            ErrorReader errorReader = new ErrorReader();

            if (Math.Abs(model.Xcoord) > 90 || Math.Abs(model.Ycoord) > 180)
            {
                var       message = string.Format(errorReader.GetErrorMessage(0));
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(errorReader.GetError(0), err));
            }
            else
            {
                if (model.Nome.Equals("") || model.Password.Equals(""))
                {
                    var       message = string.Format(errorReader.GetErrorMessage(8));
                    HttpError err     = new HttpError(message);
                    return(Request.CreateResponse(errorReader.GetError(8), err));
                }
                else
                {
                    SalaAccess sala = new SalaAccess();

                    SalaCriarModel smodel = new SalaCriarModel();

                    smodel.UserId        = RequestContext.Principal.Identity.GetUserId();
                    smodel.Nome          = model.Nome;
                    smodel.Password      = model.Password;
                    smodel.Xcoord        = model.Xcoord;
                    smodel.Ycoord        = model.Ycoord;
                    smodel.LimiteMusicas = model.LimiteMusicas;
                    smodel.LimiteHorario = model.LimiteHorario;

                    return(Request.CreateResponse(HttpStatusCode.OK, sala.CriaSala(smodel)));
                }
            }
        }
예제 #2
0
        public int CriaSala(SalaCriarModel model)
        {
            SqlDataAccess sql = new SqlDataAccess();

            return(sql.LoadData <int, dynamic>("dbo.spCriaSala", model, "WebAPIData").FirstOrDefault());
        }