// Puts a serialized fixit onto the queue. public async Task SendMessageAsync(FixItTask fixIt) { CloudQueue queue = _queueClient.GetQueueReference(fixitQueueName); await queue.CreateIfNotExistsAsync(); var fixitJson = JsonConvert.SerializeObject(fixIt); CloudQueueMessage message = new CloudQueueMessage(fixitJson); await queue.AddMessageAsync(message); }
// GET: /Dashboard/Edit/5 public async Task <ActionResult> Edit(int id) { FixItTask fixittask = await this.fixItRepository.FindTaskByIdAsync(id); if (fixittask == null) { return(this.HttpNotFound()); } return(this.View(fixittask)); }
// // GET: /Dashboard/Details/5 public async Task <ActionResult> Details(int id) { FixItTask fixItTask = await fixItRepository.FindTaskByIdAsync(id); if (fixItTask == null) { return(HttpNotFound()); } return(View(fixItTask)); }
public async Task <ActionResult> Create([Bind(Include = "FixItTaskId,CreatedBy,Owner,Title,Notes,PhotoUrl,IsDone")] FixItTask fixittask, HttpPostedFileBase photo) { if (ModelState.IsValid) { fixittask.CreatedBy = User.Identity.Name; await service.CreateAsync(fixittask, photo); return(RedirectToAction("Success")); } return(View(fixittask)); }
public async Task <ActionResult> Edit(int id, FormCollection form) { FixItTask fixittask = await this.fixItRepository.FindTaskByIdAsync(id); if (this.TryUpdateModel(fixittask, form)) { await this.fixItRepository.UpdateAsync(fixittask); return(this.RedirectToAction("Index")); } return(this.View(fixittask)); }
public async Task <ActionResult> Create(FixItTask fixittask, HttpPostedFileBase photo) { if (ModelState.IsValid) { fixittask.CreatedBy = User.Identity.Name; fixittask.PhotoUrl = this.photoService.UploadPhoto(photo); await this.fixItRepository.CreateAsync(fixittask); return(this.RedirectToAction("Success")); } return(this.View(fixittask)); }
// Puts a serialized fixit onto the queue. public async Task SendMessageAsync(FixItTask fixIt) { CloudQueue queue = queueClient.GetQueueReference(FixitQueueName); await queue.CreateIfNotExistsAsync(); var fixitJson = JsonConvert.SerializeObject(new FixItTaskMessage { Task = fixIt, OperationId = CorrelationManager.GetOperationId() }); CloudQueueMessage message = new CloudQueueMessage(fixitJson); await queue.AddMessageAsync(message); }
// // GET: /Dashboard/Edit/5 public async Task <ActionResult> Edit(int id) { FixItTask fixittask = await fixItRepository.FindTaskByIdAsync(id); if (fixittask == null) { return(HttpNotFound()); } // Verify logged in user owns this FixIt task. if (User.Identity.Name != fixittask.Owner) { return(HttpNotFound()); } return(View(fixittask)); }
public async Task CreateAsync(FixItTask taskToAdd) { var timespan = Stopwatch.StartNew(); try { await repository.CreateAsync(taskToAdd); timespan.Stop(); logger.TraceApi("SQL Database", "FixItTaskRepository.CreateAsync", timespan.Elapsed, "taskToAdd={0}", taskToAdd); } catch (Exception e) { logger.Error(e, "Error in FixItTaskRepository.CreateAsync(taskToAdd={0})", taskToAdd); throw; } }
public async Task CreateAsync(FixItTask task, HttpPostedFileBase photo) { if (task.Notes.Contains("fail me")) { throw new Exception("Task cannot be created"); } task.PhotoUrl = await photoService.UploadPhotoAsync(photo); if (ConfigurationManager.AppSettings["UseQueues"] == "true") { await queueManager.SendMessageAsync(task); } else { await fixItRepository.CreateAsync(task); } }
public async Task<FixItTask> FindTaskByIdAsync(int id) { FixItTask fixItTask = null; Stopwatch timespan = Stopwatch.StartNew(); try { fixItTask = await db.FixItTasks.FindAsync(id); timespan.Stop(); log.TraceApi("SQL Database", "FixItTaskRepository.FindTaskByIdAsync", timespan.Elapsed, "id={0}", id); } catch(Exception e) { log.Error(e, "Error in FixItTaskRepository.FindTaskByIdAsynx(id={0})", id); } return fixItTask; }
// Processes any messages on the queue. public async Task ProcessMessagesAsync() { CloudQueue queue = _queueClient.GetQueueReference(fixitQueueName); await queue.CreateIfNotExistsAsync(); while (true) { CloudQueueMessage message = await queue.GetMessageAsync(); if (message == null) { break; } FixItTask fixit = JsonConvert.DeserializeObject <FixItTask>(message.AsString); await _repository.CreateAsync(fixit); await queue.DeleteMessageAsync(message); } }
public async Task <ActionResult> Edit(int id, [Bind(Include = "CreatedBy,Owner,Title,Notes,PhotoUrl,IsDone")] FormCollection form) { FixItTask fixittask = await fixItRepository.FindTaskByIdAsync(id); // Verify logged in user owns this FixIt task. if (User.Identity.Name != fixittask.Owner) { return(HttpNotFound()); } if (TryUpdateModel(fixittask, form)) { await fixItRepository.UpdateAsync(fixittask); return(RedirectToAction("Index")); } return(View(fixittask)); }
public async Task <ActionResult> Create([Bind(Include = "FixItTaskId,CreatedBy,Owner,Title,Notes,PhotoUrl,IsDone")] FixItTask fixittask, HttpPostedFileBase photo) { if (ModelState.IsValid) { fixittask.CreatedBy = User.Identity.Name; fixittask.PhotoUrl = await _photoService.UploadPhotoAsync(photo); if (ConfigurationManager.AppSettings["UseQueues"] == "true") { await _queueManager.SendMessageAsync(fixittask); } else { await _fixItRepository.CreateAsync(fixittask); } return(RedirectToAction("Success")); } return(View(fixittask)); }
public async Task CreateAsync(FixItTask task, HttpPostedFileBase photo) { var stopWatch = new Stopwatch(); stopWatch.Start(); try { await service.CreateAsync(task, photo); } finally { stopWatch.Stop(); var properties = new Dictionary <string, string> { { "Title", task.Title }, { "Owner", task.Owner } }; TrackEvent("Create", stopWatch.Elapsed, properties); } }
public Task CreateAsync(FixItTask taskToAdd) { context.FixItTasks.Add(taskToAdd); return context.SaveChangesAsync(); }
public Task UpdateAsync(FixItTask taskToSave) { context.Entry(taskToSave).State = EntityState.Modified; return context.SaveChangesAsync(); }