Validated book queries are obsolete

main
Paul Schneider 9 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 now = DateTime.Now;
var result = _context.Commands.Include(c => c.Location). 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 Select(c => new BookQueryProviderInfo
{ {
Client = new ClientProviderInfo { Client = new ClientProviderInfo {

@ -1,3 +1,4 @@
using System;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
@ -124,8 +125,15 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState); 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.Estimates.Add(estimate);
/* _context.AttachRange(estimate.Bill); /* _context.AttachRange(estimate.Bill);
_context.Attach(estimate); _context.Attach(estimate);
_context.Entry(estimate).State = EntityState.Added; _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…