public IHttpActionResult PutTicket(int id, Ticket ticket) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ticket.TicketID) { return(BadRequest()); } db.Entry(ticket).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TicketExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(Events events) { if (ModelState.IsValid) { db.Events.Add(events); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(events)); }
public ActionResult Create([Bind(Include = "TransportID,TransportType,Capacity,Bathroom")] Transport transport) { if (ModelState.IsValid) { db.Transports.Add(transport); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(transport)); }
public ActionResult Create([Bind(Include = "CompanyID,Name,FoundedYear,Description")] EventCompany eventCompany) { if (ModelState.IsValid) { db.EventCompanies.Add(eventCompany); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventCompany)); }
public ActionResult Create([Bind(Include = "PersonID,Name,Surname,DNI")] Person person) { if (ModelState.IsValid) { db.Persons.Add(person); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(person)); }
public ActionResult Create([Bind(Include = "CountryID,Name,Currency,Change")] Country country) { if (ModelState.IsValid) { db.Countries.Add(country); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
public ActionResult Create([Bind(Include = "CityID,CityName,CountryID")] City city) { if (ModelState.IsValid) { db.Cities.Add(city); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "Name", city.CountryID); return(View(city)); }
public ActionResult Create([Bind(Include = "Id,Name,Location,StartDate,EndDate")] Event eve) { ModelState.Clear(); if (ModelState.IsValid) { db.Events.Add(eve); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eve)); }
private void GenerateSignInSheetTableStorage(EventsContext context, Event eventItem) { string connectionString = CloudConfigurationManager.GetSetting("Microsoft.WindowsAzure.Storage.ConnectionString"); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); string signInQueueName = WebConfigurationManager.AppSettings["SignInQueueName"]; CloudQueue queue = queueClient.GetQueueReference(signInQueueName); queue.CreateIfNotExists(); string queueMessage = JsonConvert.SerializeObject( new QueueMessage { EventId = eventItem.Id, MessageType = QueueMessageType.SignIn } ); queue.AddMessage( new CloudQueueMessage(queueMessage) ); eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
public ActionResult Create([Bind(Include = "EventWithTicketID,CityID,TransportID,EventDate,Description,Addres,HasTickets,MaxTicket")] EventWithTicket eventWithTicket) { if (ModelState.IsValid) { if (eventWithTicket.EventDate >= DateTime.Now) { db.EventsWithTickets.Add(eventWithTicket); db.SaveChanges(); return(RedirectToAction("Index")); } return(View("DateError")); } ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName", eventWithTicket.CityID); ViewBag.TransportID = new SelectList(db.Transports, "TransportID", "TransportType", eventWithTicket.TransportID); return(View(eventWithTicket)); }
private void GenerateSignInSheetServiceBus(EventsContext context, Event eventItem) { string serviceBusConnectionString = WebConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"]; string signInQueueName = WebConfigurationManager.AppSettings["SignInQueueName"]; NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString); QueueClient client = QueueClient.CreateFromConnectionString(serviceBusConnectionString, signInQueueName); client.Send( new BrokeredMessage( new QueueMessage { EventId = eventItem.Id, MessageType = QueueMessageType.SignIn } ) ); eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
public IActionResult Create(User user) { // UserRepository.AddUser(user); user.Created = DateTime.Now; _context.Users.Add(user); _context.SaveChanges(); return(View("Thanks", user)); }
public static void IncrementEvent(int eventId) { using (EventsContext context = new EventsContext()) { Event eventItem = context.Events.Single(e => e.Id == eventId); eventItem.RegistrationCount++; context.SaveChanges(); } }
public EventsController(EventsContext context) { _context = context; if (!_context.Events.Any()) { _context.Events.Add(new Event("new event", DateTime.Now)); _context.SaveChanges(); } }
public void PrepareData(EventsContext context, IEnumerable <DomainEvent> events) { if (events != null && events.Count() > 0) { var eventsWrapped = events.Select(ev => EventWrapper.Wrap(ev)).ToArray(); context.AddRange(eventsWrapped); context.SaveChanges(); } }
private void GenerateSignInSheetTableStorage(EventsContext context, Event eventItem, string message) { eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
private void GenerateSignInSheetServiceBus(EventsContext context, Event eventItem, QueueMessage message) { eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
static void Main(string[] args) { Console.WriteLine("Starting the batch"); var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]); var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("EventRegistrations"); Console.WriteLine("Create table storage EventRegistrations if not exists"); table.CreateIfNotExists(); List <Registration> registrationList = new List <Registration>(); string dbConnectionString = ConfigurationManager.ConnectionStrings["EventsContextConnectionString"].ConnectionString; bool isAzureDb = Regex.IsMatch(dbConnectionString, PATTERN_AZURE_CONNECTION, RegexOptions.Compiled); if (!isAzureDb) { Console.WriteLine("Deleting sql database"); using (EventsContext context = new EventsContext()) { context.Database.Delete(); } } using (EventsContext context = new EventsContext()) { Console.WriteLine("Removing data from database"); context.Events.RemoveRange(context.Events); context.SaveChanges(); Console.WriteLine("Adding data to database"); for (int i = 0; i < 55; i++) { var result = CreateEvent(context); registrationList.AddRange(result); } } registrationList = registrationList.OrderBy(r => rand.Next()).ToList(); Console.WriteLine("adding data to table storage"); foreach (var registrationGroup in registrationList.GroupBy(r => r.PartitionKey)) { TableBatchOperation operation = new TableBatchOperation(); foreach (var registration in registrationGroup) { operation.Insert(registration); } table.ExecuteBatch(operation); } }
public IActionResult Post([FromBody] Users newUser) { var existingUser = _db.Users.Where(user => user.Username == newUser.Username).ToList(); if (existingUser.Count == 0) { _db.Users.Add(newUser); _db.SaveChanges(); return(Ok()); } return(StatusCode(400)); }
public IActionResult Post([FromBody] Events newEvent) { try { _db.Events.Add(newEvent); _db.SaveChanges(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex)); } }
// PUT api/EventRecords/5 public HttpResponseMessage PutEventRecord(int id, EventRecord eventrecord) { if (ModelState.IsValid && id == eventrecord.Id) { db.Entry(eventrecord).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public IActionResult Post([FromBody] Categories newCategory) { try { _db.Categories.Add(newCategory); _db.SaveChanges(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex)); } }
private void GenerateSignInSheetServiceBus(EventsContext context, Event eventItem, QueueMessage message) { eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; QueueClient queueClient = QueueClient.CreateFromConnectionString(serviceBusConnectionString, signInQueueName); queueClient.Send(new BrokeredMessage(message)); }
public static void Initialize(EventsContext context) { context.Events.Add( new Events { Id = 001, Name = "*****@*****.**", Type = "123", Description = "Vasya", Date = DateTime.Today } ); context.SaveChanges(); }
public void GenerateSignInSheet(int eventId) { using (EventsContext context = new EventsContext()) { var eventItem = context.Events.SingleOrDefault(e => e.Id == eventId); eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; } this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
private static void HandleSignInMessage(QueueMessage message) { using (EventsContext context = new EventsContext()) { Event eventItem = context.Events.SingleOrDefault(e => e.Id == message.EventId); using (MemoryStream stream = _documentGenerator.CreateSignInDocument(eventItem)) { Uri documentUrl = _blobManager.CreateBlob(stream, eventItem.EventKey); eventItem.SignInDocumentUrl = documentUrl.AbsoluteUri; } context.SaveChanges(); } }
private void GenerateSignInSheetTableStorage(EventsContext context, Event eventItem, string message) { eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; CloudStorageAccount account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["Microsoft.WindowsAzure.Storage.ConnectionString"]); CloudQueueClient client = account.CreateCloudQueueClient(); CloudQueue queue = client.GetQueueReference(signInQueueName); queue.AddMessage(new CloudQueueMessage(message)); }
public SignInViewModel(string eventKey) { using (EventsContext context = new EventsContext()) { context.SignInDocuments.Add( new SignInDocument { EventKey = eventKey, Generated = false, Document = null } ); context.SaveChanges(); } }
public bool PersistRegistration() { using (EventsContext context = new EventsContext()) { this.Event = context.Events.SingleOrDefault(e => e.EventKey == this.Event.EventKey); this.Registration.Timestamp = DateTime.Now; this.Registration.Event = this.Event; this.Registration = context.EventRegistrants.Add(this.Registration); context.SaveChanges(); return(true); } }
private static void HandleSignInMessage(QueueMessage message) { using (EventsContext context = new EventsContext()) { var eventItem = context.Events.SingleOrDefault(e => e.Id == message.EventId); IEnumerable <string> names = _tableHelper.GetRegistrantNames(eventItem.EventKey); using (MemoryStream stream = _documentGenerator.CreateSignInDocument(eventItem.Title, names)) { Uri documentUrl = _blobHelper.CreateBlob(stream, eventItem.EventKey); eventItem.SignInDocumentUrl = documentUrl.AbsoluteUri; } context.SaveChanges(); } }
static void Main(string[] args) { var storageAccount = CloudStorageAccount.DevelopmentStorageAccount; var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("EventRegistrations"); table.DeleteIfExists(); table.CreateIfNotExists(); List<Registration> registrationList = new List<Registration>(); using (EventsContext context = new EventsContext()) { context.Database.Delete(); } using (EventsContext context = new EventsContext()) { context.Events.RemoveRange(context.Events); context.SaveChanges(); for (int i = 0; i < 55; i++) { var result = CreateEvent(context); registrationList.AddRange(result); } } registrationList = registrationList.OrderBy(r => rand.Next()).ToList(); foreach (var registrationGroup in registrationList.GroupBy(r => r.PartitionKey)) { TableBatchOperation operation = new TableBatchOperation(); foreach (var registration in registrationGroup) { operation.Insert(registration); } table.ExecuteBatch(operation); } }
public static List<Registration> CreateEvent(EventsContext context) { var latLong = latLongs[rand.Next(0, latLongs.Count)]; var location = DbGeography.PointFromText(String.Format("POINT({0} {1})", latLong.Value, latLong.Key), 4326); var startTime = new DateTime(rand.Next(DateTime.Today.Year + 1, DateTime.Today.Year + 7), rand.Next(1, 13), rand.Next(1, 29), rand.Next(9, 22), rand.Next(0, 60), 0); var eventType = types[rand.Next(0, types.Count)]; var name = String.Format("FY{0:yy} {0:MMMM} {1}", startTime, eventType.Key); var description = descriptions[rand.Next(0, descriptions.Length)]; var registrationCount = (short)rand.Next(0, 55); var eventKey = String.Format("FY{0:yyMMM}{1}", startTime, eventType.Value == typeof(Registration) ? "GeneralConference" : eventType.Value.Name.Replace("Registration", String.Empty)); int previousCount = context.Events.Count(e => e.EventKey.StartsWith(eventKey)); if (previousCount > 0) { eventKey += (previousCount + 1); } var eventResult = context.Events.Add(new Event { EventKey = eventKey, StartTime = startTime, EndTime = startTime.AddDays(3.5d), Title = name, Description = description, RegistrationCount = registrationCount, Location = location }); context.SaveChanges(); List<Registration> registrationList = new List<Registration>(); if (eventType.Value == typeof(Registration)) { registrationList.Add(new Registration(String.Format("Stub_{0}", eventResult.EventKey)) { IsStub = true }); } else if (eventType.Value == typeof(TechnicalConferenceRegistration)) { registrationList.Add(new TechnicalConferenceRegistration(String.Format("Stub_{0}", eventResult.EventKey)) { IsStub = true }); } else if (eventType.Value == typeof(SalesConferenceRegistration)) { registrationList.Add(new SalesConferenceRegistration(String.Format("Stub_{0}", eventResult.EventKey)) { IsStub = true, Region = String.Empty }); } else if (eventType.Value == typeof(InternalConferenceRegistration)) { registrationList.Add(new InternalConferenceRegistration(String.Format("Stub_{0}", eventResult.EventKey)) { IsStub = true, EmployeeID = String.Empty, Department = String.Empty }); } for (int i = 0; i < registrationCount; i++) { string personName = names.Except(new string[] { name }).ToList()[rand.Next(0, names.Length - 1)]; string firstName = personName.Split(' ')[0]; string lastName = personName.Split(' ')[1]; string region = regions[rand.Next(0, regions.Length)]; string department = departments[rand.Next(0, departments.Length)]; string employeeID = Guid.NewGuid().ToString().Substring(0, 8).ToUpper(); int numberOfKeyFobs = rand.Next(1, 5); int annualSales = rand.Next(15000, 350000); bool onMainCampus = Convert.ToBoolean(rand.Next(0, 2)); if (eventType.Value == typeof(Registration)) { registrationList.Add(new Registration(eventResult.EventKey) { FirstName = firstName, LastName = lastName }); } else if (eventType.Value == typeof(TechnicalConferenceRegistration)) { registrationList.Add(new TechnicalConferenceRegistration(eventResult.EventKey) { FirstName = firstName, LastName = lastName, NumberOfKeyFobs = numberOfKeyFobs }); } else if (eventType.Value == typeof(SalesConferenceRegistration)) { registrationList.Add(new SalesConferenceRegistration(eventResult.EventKey) { FirstName = firstName, LastName = lastName, AnnualSales = annualSales }); } else if (eventType.Value == typeof(InternalConferenceRegistration)) { registrationList.Add(new InternalConferenceRegistration(eventResult.EventKey) { FirstName = firstName, LastName = lastName, EmployeeID = employeeID, Department = department }); } } return registrationList; }