Exemple #1
0
        public Task <int> PostAsync(CreateEvent item)
        {
            return(Task.Factory.StartNew(() =>
            {
                SqlParameter sponsors;
                SqlParameter tags;
                format_tags_and_sponsors_to_parameter(item.Tags, null, out sponsors, out tags);

                var title = SqlParameterFactory.getVarCharParameter("title", item.title);
                var local = SqlParameterFactory.getVarCharParameter("local", item.local);
                var description = SqlParameterFactory.getVarCharParameter("description", item.description);
                var endDate = SqlParameterFactory.getDateParameter("endDate", item.endDate);
                var initDate = SqlParameterFactory.getDateParameter("initDate", item.initDate);
                var nrTickets = SqlParameterFactory.getIntParameter("nrTickets", item.nrOfTickets);
                var communityId = SqlParameterFactory.getIntParameter("communityId", item.communityId);
                var latitude = SqlParameterFactory.getVarCharParameter("latitude", item.latitude);
                var longitude = SqlParameterFactory.getVarCharParameter("longitude", item.longitude);
                var qrcode = SqlParameterFactory.getVarCharParameter("qrcode", item.qrcode);

                ////Parameter for SP output
                var result = new SqlParameter("result", SqlDbType.Int);
                result.Direction = ParameterDirection.Output;

                try
                {
                    context.Database.ExecuteSqlCommand("EXEC insert_event @communityId,@title,@local,@description,@nrTickets,@initDate,@endDate,@tags,@latitude,@longitude,@qrcode,@result OUTPUT", communityId, title, local, description, nrTickets, initDate, endDate, tags, latitude, longitude, qrcode, result);
                    return Convert.ToInt32(result.Value);
                }
                catch (SqlException ex)
                {
                    throw new ArgumentException(ex.Message);
                }
            }));
        }
Exemple #2
0
        protected Task <string> N_To_N_operation(int entityId, string userId, string query)
        {
            return(Task.Factory.StartNew(() =>
            {
                try
                {
                    var id = SqlParameterFactory.getIntParameter("id", entityId);
                    var uId = SqlParameterFactory.getVarCharParameter("userId", userId);

                    context.Database.ExecuteSqlCommand(query, id, uId);

                    return userId;
                }
                catch (SqlException ex)
                {
                    throw new ArgumentException(ex.Message);
                }
            }));
        }
Exemple #3
0
        protected Task <bool> Sponsors_N_To_N_operations(int communityId, int[] sponsors, string query)
        {
            return(Task.Factory.StartNew(() =>
            {
                SqlParameter sponsor;
                SqlParameter tag;
                format_tags_and_sponsors_to_parameter(null, sponsors, out sponsor, out tag);
                var id = SqlParameterFactory.getIntParameter("communityId", communityId);

                try
                {
                    context.Database.ExecuteSqlCommand(query, sponsor, id);

                    return true;
                }
                catch (SqlException ex)
                {
                    throw new ArgumentException(ex.Message);
                }
            }));
        }