Validated book queries are obsolete

vnext
Paul Schneider 8 years ago
parent eaea3f6600
commit 3d3d38e023
3 changed files with 48 additions and 2 deletions

@ -41,7 +41,8 @@ namespace Yavsc.Controllers
var now = DateTime.Now;
var result = _context.Commands.Include(c => c.Location).
Include(c => c.Client).Where(c => c.PerformerId == uid && c.Id < maxId && c.EventDate > now).
Include(c => c.Client).Where(c => c.PerformerId == uid && c.Id < maxId && c.EventDate > now
&& c.ValidationDate == null).
Select(c => new BookQueryProviderInfo
{
Client = new ClientProviderInfo {

@ -1,3 +1,4 @@
using System;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNet.Authorization;
@ -124,8 +125,15 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState);
}
}
if (estimate.CommandId!=null) {
var query = _context.BookQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
if (query == null || query.PerformerId!= uid)
throw new InvalidOperationException();
query.ValidationDate = DateTime.Now;
}
_context.Estimates.Add(estimate);
/* _context.AttachRange(estimate.Bill);
_context.Attach(estimate);
_context.Entry(estimate).State = EntityState.Added;

@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models.Access
{
public class BlackListed
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public string UserId { get; set; }
public long ListId { get; set; }
[ForeignKey("ListId")]
public virtual BlackList BlackList { get; set; }
}
public class BlackList
{
public BlackList(long id, string target)
{
this.Id = id;
this.Target = target;
}
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public string Target { get; set; }
[InverseProperty("BlackList")]
public virtual List<BlackListed> Items
{
get; set;
}
}
}
Loading…