diff --git a/Yavsc/ApiControllers/EstimateTemplatesApiController.cs b/Yavsc/ApiControllers/EstimateTemplatesApiController.cs new file mode 100644 index 00000000..921ff548 --- /dev/null +++ b/Yavsc/ApiControllers/EstimateTemplatesApiController.cs @@ -0,0 +1,159 @@ +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Mvc; +using Microsoft.Data.Entity; +using Yavsc.Models; +using Yavsc.Models.Billing; + +namespace Yavsc.Controllers +{ + [Produces("application/json")] + [Route("api/EstimateTemplatesApi")] + public class EstimateTemplatesApiController : Controller + { + private ApplicationDbContext _context; + + public EstimateTemplatesApiController(ApplicationDbContext context) + { + _context = context; + } + + // GET: api/EstimateTemplatesApi + [HttpGet] + public IEnumerable GetEstimateTemplate() + { + var uid = User.GetUserId(); + return _context.EstimateTemplates.Where(x=>x.OwnerId==uid); + } + + // GET: api/EstimateTemplatesApi/5 + [HttpGet("{id}", Name = "GetEstimateTemplate")] + public IActionResult GetEstimateTemplate([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + var uid = User.GetUserId(); + + EstimateTemplate estimateTemplate = _context.EstimateTemplates.Where(x=>x.OwnerId==uid).Single(m => m.Id == id); + + if (estimateTemplate == null) + { + return HttpNotFound(); + } + + return Ok(estimateTemplate); + } + + // PUT: api/EstimateTemplatesApi/5 + [HttpPut("{id}")] + public IActionResult PutEstimateTemplate(long id, [FromBody] EstimateTemplate estimateTemplate) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + if (id != estimateTemplate.Id) + { + return HttpBadRequest(); + } + var uid = User.GetUserId(); + if (estimateTemplate.OwnerId!=uid) + if (!User.IsInRole(Constants.AdminGroupName)) + return new HttpStatusCodeResult(StatusCodes.Status403Forbidden); + + _context.Entry(estimateTemplate).State = EntityState.Modified; + + try + { + _context.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!EstimateTemplateExists(id)) + { + return HttpNotFound(); + } + else + { + throw; + } + } + + return new HttpStatusCodeResult(StatusCodes.Status204NoContent); + } + + // POST: api/EstimateTemplatesApi + [HttpPost] + public IActionResult PostEstimateTemplate([FromBody] EstimateTemplate estimateTemplate) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + estimateTemplate.OwnerId=User.GetUserId(); + + _context.EstimateTemplates.Add(estimateTemplate); + try + { + _context.SaveChanges(); + } + catch (DbUpdateException) + { + if (EstimateTemplateExists(estimateTemplate.Id)) + { + return new HttpStatusCodeResult(StatusCodes.Status409Conflict); + } + else + { + throw; + } + } + + return CreatedAtRoute("GetEstimateTemplate", new { id = estimateTemplate.Id }, estimateTemplate); + } + + // DELETE: api/EstimateTemplatesApi/5 + [HttpDelete("{id}")] + public IActionResult DeleteEstimateTemplate(long id) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + EstimateTemplate estimateTemplate = _context.EstimateTemplates.Single(m => m.Id == id); + if (estimateTemplate == null) + { + return HttpNotFound(); + } + var uid = User.GetUserId(); + if (estimateTemplate.OwnerId!=uid) + if (!User.IsInRole(Constants.AdminGroupName)) + return new HttpStatusCodeResult(StatusCodes.Status403Forbidden); + + _context.EstimateTemplates.Remove(estimateTemplate); + _context.SaveChanges(); + + return Ok(estimateTemplate); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + _context.Dispose(); + } + base.Dispose(disposing); + } + + private bool EstimateTemplateExists(long id) + { + return _context.EstimateTemplates.Count(e => e.Id == id) > 0; + } + } +} \ No newline at end of file diff --git a/Yavsc/ApiControllers/PostRateApiController.cs b/Yavsc/ApiControllers/PostRateApiController.cs new file mode 100644 index 00000000..8639a97d --- /dev/null +++ b/Yavsc/ApiControllers/PostRateApiController.cs @@ -0,0 +1,47 @@ +using System.Linq; +using System.Security.Claims; +using Microsoft.AspNet.Authorization; +using Microsoft.AspNet.Mvc; +using Yavsc.Models; + +namespace Yavsc.Controllers +{ + [Produces("application/json")] + [Route("api/PostRateApi")] + public class PostRateApiController : Controller + { + private ApplicationDbContext _context; + + public PostRateApiController(ApplicationDbContext context) + { + _context = context; + } + + // GET: api/PostRateApi/5 + [HttpPut("{id}"),Authorize] + public IActionResult PutPostRate([FromRoute] long id, [FromBody] int rate) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + Blog blogpost = _context.Blogspot.Single(x=>x.Id == id); + + if (blogpost == null) + { + return HttpNotFound(); + } + + var uid = User.GetUserId(); + if (blogpost.AuthorId!=uid) + if (!User.IsInRole(Constants.AdminGroupName)) + return HttpBadRequest(); + + blogpost.Rate = rate; + _context.SaveChanges(); + + return Ok(); + } + } +} diff --git a/Yavsc/ApiControllers/PostTagsApiController.cs b/Yavsc/ApiControllers/PostTagsApiController.cs new file mode 100644 index 00000000..97fb0282 --- /dev/null +++ b/Yavsc/ApiControllers/PostTagsApiController.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Mvc; +using Microsoft.Data.Entity; +using Yavsc.Models; + +namespace Yavsc.Controllers +{ + [Produces("application/json")] + [Route("api/PostTagsApi")] + public class PostTagsApiController : Controller + { + private ApplicationDbContext _context; + + public PostTagsApiController(ApplicationDbContext context) + { + _context = context; + } + + // GET: api/PostTagsApi + [HttpGet] + public IEnumerable GetTagsDomain() + { + return _context.TagsDomain; + } + + // GET: api/PostTagsApi/5 + [HttpGet("{id}", Name = "GetPostTag")] + public IActionResult GetPostTag([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + PostTag postTag = _context.TagsDomain.Single(m => m.PostId == id); + + if (postTag == null) + { + return HttpNotFound(); + } + + return Ok(postTag); + } + + // PUT: api/PostTagsApi/5 + [HttpPut("{id}")] + public IActionResult PutPostTag(long id, [FromBody] PostTag postTag) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + if (id != postTag.PostId) + { + return HttpBadRequest(); + } + + _context.Entry(postTag).State = EntityState.Modified; + + try + { + _context.SaveChanges(); + } + catch (DbUpdateConcurrencyException) + { + if (!PostTagExists(id)) + { + return HttpNotFound(); + } + else + { + throw; + } + } + + return new HttpStatusCodeResult(StatusCodes.Status204NoContent); + } + + // POST: api/PostTagsApi + [HttpPost] + public IActionResult PostPostTag([FromBody] PostTag postTag) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + _context.TagsDomain.Add(postTag); + try + { + _context.SaveChanges(); + } + catch (DbUpdateException) + { + if (PostTagExists(postTag.PostId)) + { + return new HttpStatusCodeResult(StatusCodes.Status409Conflict); + } + else + { + throw; + } + } + + return CreatedAtRoute("GetPostTag", new { id = postTag.PostId }, postTag); + } + + // DELETE: api/PostTagsApi/5 + [HttpDelete("{id}")] + public IActionResult DeletePostTag(long id) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + PostTag postTag = _context.TagsDomain.Single(m => m.PostId == id); + if (postTag == null) + { + return HttpNotFound(); + } + + _context.TagsDomain.Remove(postTag); + _context.SaveChanges(); + + return Ok(postTag); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + _context.Dispose(); + } + base.Dispose(disposing); + } + + private bool PostTagExists(long id) + { + return _context.TagsDomain.Count(e => e.PostId == id) > 0; + } + } +} \ No newline at end of file diff --git a/Yavsc/Interfaces/IBillingClause.cs b/Yavsc/Interfaces/IBillingClause.cs index 48e23c9f..149b8d47 100644 --- a/Yavsc/Interfaces/IBillingClause.cs +++ b/Yavsc/Interfaces/IBillingClause.cs @@ -1,6 +1,7 @@ - +namespace Yavsc.Models.Billing { public interface IBillingClause {  string Description {get; set;} IBillingImpacter Impacter { get; } } +} \ No newline at end of file diff --git a/Yavsc/Migrations/20160905095708_tags.Designer.cs b/Yavsc/Migrations/20160905095708_tags.Designer.cs new file mode 100644 index 00000000..1f1d3588 --- /dev/null +++ b/Yavsc/Migrations/20160905095708_tags.Designer.cs @@ -0,0 +1,726 @@ +using System; +using Microsoft.Data.Entity; +using Microsoft.Data.Entity.Infrastructure; +using Microsoft.Data.Entity.Metadata; +using Microsoft.Data.Entity.Migrations; +using Yavsc.Models; + +namespace Yavsc.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20160905095708_tags")] + partial class tags + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0-rc1-16348"); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRole", b => + { + b.Property("Id"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Name") + .HasAnnotation("MaxLength", 256); + + b.Property("NormalizedName") + .HasAnnotation("MaxLength", 256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .HasAnnotation("Relational:Name", "RoleNameIndex"); + + b.HasAnnotation("Relational:TableName", "AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("RoleId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasAnnotation("Relational:TableName", "AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasAnnotation("Relational:TableName", "AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b => + { + b.Property("LoginProvider"); + + b.Property("ProviderKey"); + + b.Property("ProviderDisplayName"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasAnnotation("Relational:TableName", "AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasAnnotation("Relational:TableName", "AspNetUserRoles"); + }); + + modelBuilder.Entity("Yavsc.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Address") + .IsRequired(); + + b.Property("Latitude"); + + b.Property("Longitude"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.AccountBalance", b => + { + b.Property("UserId"); + + b.Property("ContactCredits"); + + b.Property("Credits"); + + b.HasKey("UserId"); + }); + + modelBuilder.Entity("Yavsc.Models.Activity", b => + { + b.Property("Code") + .HasAnnotation("MaxLength", 512); + + b.Property("ActorDenomination"); + + b.Property("Description"); + + b.Property("ModeratorGroupName"); + + b.Property("Name") + .IsRequired() + .HasAnnotation("MaxLength", 512); + + b.Property("Photo"); + + b.HasKey("Code"); + }); + + modelBuilder.Entity("Yavsc.Models.ApplicationUser", b => + { + b.Property("Id"); + + b.Property("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("DedicatedGoogleCalendar"); + + b.Property("Email") + .HasAnnotation("MaxLength", 256); + + b.Property("EmailConfirmed"); + + b.Property("LockoutEnabled"); + + b.Property("LockoutEnd"); + + b.Property("NormalizedEmail") + .HasAnnotation("MaxLength", 256); + + b.Property("NormalizedUserName") + .HasAnnotation("MaxLength", 256); + + b.Property("PasswordHash"); + + b.Property("PhoneNumber"); + + b.Property("PhoneNumberConfirmed"); + + b.Property("PostalAddressId"); + + b.Property("SecurityStamp"); + + b.Property("TwoFactorEnabled"); + + b.Property("UserName") + .HasAnnotation("MaxLength", 256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasAnnotation("Relational:Name", "EmailIndex"); + + b.HasIndex("NormalizedUserName") + .HasAnnotation("Relational:Name", "UserNameIndex"); + + b.HasAnnotation("Relational:TableName", "AspNetUsers"); + }); + + modelBuilder.Entity("Yavsc.Models.Auth.Client", b => + { + b.Property("Id"); + + b.Property("Active"); + + b.Property("DisplayName"); + + b.Property("LogoutRedirectUri") + .HasAnnotation("MaxLength", 100); + + b.Property("RedirectUri"); + + b.Property("RefreshTokenLifeTime"); + + b.Property("Secret"); + + b.Property("Type"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Auth.RefreshToken", b => + { + b.Property("Id"); + + b.Property("ClientId") + .IsRequired() + .HasAnnotation("MaxLength", 50); + + b.Property("ExpiresUtc"); + + b.Property("IssuedUtc"); + + b.Property("ProtectedTicket") + .IsRequired(); + + b.Property("Subject") + .IsRequired() + .HasAnnotation("MaxLength", 50); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.BalanceImpact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BalanceId") + .IsRequired(); + + b.Property("ExecDate"); + + b.Property("Impact"); + + b.Property("Reason") + .IsRequired(); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Billing.CommandLine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ArticleId"); + + b.Property("BookQueryId"); + + b.Property("Comment"); + + b.Property("Count"); + + b.Property("EstimateId"); + + b.Property("UnitaryCost"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Billing.Estimate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AttachedFilesString"); + + b.Property("AttachedGraphicsString"); + + b.Property("ClientId") + .IsRequired(); + + b.Property("CommandId"); + + b.Property("Description"); + + b.Property("OwnerId") + .IsRequired(); + + b.Property("Status"); + + b.Property("Title"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Billing.ExceptionSIREN", b => + { + b.Property("SIREN"); + + b.HasKey("SIREN"); + }); + + modelBuilder.Entity("Yavsc.Models.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuthorId"); + + b.Property("Content"); + + b.Property("Modified"); + + b.Property("Photo"); + + b.Property("Posted") + .ValueGeneratedOnAdd() + .HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP"); + + b.Property("Rate"); + + b.Property("Title"); + + b.Property("Visible"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Booking.BookQuery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClientId") + .IsRequired(); + + b.Property("CreationDate") + .ValueGeneratedOnAdd() + .HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP"); + + b.Property("EventDate"); + + b.Property("Lag"); + + b.Property("LocationId"); + + b.Property("PerformerId") + .IsRequired(); + + b.Property("Previsional"); + + b.Property("ValidationDate"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Circle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApplicationUserId"); + + b.Property("Name"); + + b.Property("OwnerId"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.CircleMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CircleId"); + + b.Property("MemberId") + .IsRequired(); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Contact", b => + { + b.Property("OwnerId"); + + b.Property("UserId"); + + b.HasKey("OwnerId", "UserId"); + }); + + modelBuilder.Entity("Yavsc.Models.Identity.GoogleCloudMobileDeclaration", b => + { + b.Property("DeviceId"); + + b.Property("DeclarationDate") + .ValueGeneratedOnAdd() + .HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP"); + + b.Property("DeviceOwnerId"); + + b.Property("GCMRegistrationId") + .IsRequired(); + + b.Property("Model"); + + b.Property("Platform"); + + b.Property("Version"); + + b.HasKey("DeviceId"); + }); + + modelBuilder.Entity("Yavsc.Models.Market.BaseProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("Name"); + + b.Property("Public"); + + b.HasKey("Id"); + + b.HasAnnotation("Relational:DiscriminatorProperty", "Discriminator"); + + b.HasAnnotation("Relational:DiscriminatorValue", "BaseProduct"); + }); + + modelBuilder.Entity("Yavsc.Models.Market.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ContextId"); + + b.Property("Description"); + + b.Property("Name"); + + b.Property("Public"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.OAuth.OAuth2Tokens", b => + { + b.Property("UserId"); + + b.Property("AccessToken"); + + b.Property("Expiration"); + + b.Property("ExpiresIn"); + + b.Property("RefreshToken"); + + b.Property("TokenType"); + + b.HasKey("UserId"); + }); + + modelBuilder.Entity("Yavsc.Models.PostTag", b => + { + b.Property("PostId"); + + b.Property("TagId"); + + b.HasKey("PostId", "TagId"); + }); + + modelBuilder.Entity("Yavsc.Models.Skill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name"); + + b.Property("Rate"); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired(); + + b.HasKey("Id"); + }); + + modelBuilder.Entity("Yavsc.Models.Workflow.PerformerProfile", b => + { + b.Property("PerformerId"); + + b.Property("AcceptGeoLocalization"); + + b.Property("AcceptNotifications"); + + b.Property("AcceptPublicContact"); + + b.Property("Active"); + + b.Property("ActivityCode") + .IsRequired(); + + b.Property("MaxDailyCost"); + + b.Property("MinDailyCost"); + + b.Property("OfferId"); + + b.Property("OrganizationAddressId"); + + b.Property("Rate"); + + b.Property("SIREN") + .IsRequired() + .HasAnnotation("MaxLength", 14); + + b.Property("WebSite"); + + b.HasKey("PerformerId"); + }); + + modelBuilder.Entity("Yavsc.Models.Market.Product", b => + { + b.HasBaseType("Yavsc.Models.Market.BaseProduct"); + + b.Property("Depth"); + + b.Property("Height"); + + b.Property("Price"); + + b.Property("Weight"); + + b.Property("Width"); + + b.HasAnnotation("Relational:DiscriminatorValue", "Product"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole") + .WithMany() + .HasForeignKey("RoleId"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole") + .WithMany() + .HasForeignKey("RoleId"); + + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("Yavsc.Models.AccountBalance", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithOne() + .HasForeignKey("Yavsc.Models.AccountBalance", "UserId"); + }); + + modelBuilder.Entity("Yavsc.Models.ApplicationUser", b => + { + b.HasOne("Yavsc.Location") + .WithMany() + .HasForeignKey("PostalAddressId"); + }); + + modelBuilder.Entity("Yavsc.Models.BalanceImpact", b => + { + b.HasOne("Yavsc.Models.AccountBalance") + .WithMany() + .HasForeignKey("BalanceId"); + }); + + modelBuilder.Entity("Yavsc.Models.Billing.CommandLine", b => + { + b.HasOne("Yavsc.Models.Market.BaseProduct") + .WithMany() + .HasForeignKey("ArticleId"); + + b.HasOne("Yavsc.Models.Booking.BookQuery") + .WithMany() + .HasForeignKey("BookQueryId"); + + b.HasOne("Yavsc.Models.Billing.Estimate") + .WithMany() + .HasForeignKey("EstimateId"); + }); + + modelBuilder.Entity("Yavsc.Models.Billing.Estimate", b => + { + b.HasOne("Yavsc.Models.Booking.BookQuery") + .WithMany() + .HasForeignKey("CommandId"); + }); + + modelBuilder.Entity("Yavsc.Models.Blog", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("AuthorId"); + }); + + modelBuilder.Entity("Yavsc.Models.Booking.BookQuery", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("ClientId"); + + b.HasOne("Yavsc.Location") + .WithMany() + .HasForeignKey("LocationId"); + + b.HasOne("Yavsc.Models.Workflow.PerformerProfile") + .WithMany() + .HasForeignKey("PerformerId"); + }); + + modelBuilder.Entity("Yavsc.Models.Circle", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId"); + }); + + modelBuilder.Entity("Yavsc.Models.CircleMember", b => + { + b.HasOne("Yavsc.Models.Circle") + .WithMany() + .HasForeignKey("CircleId"); + + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("MemberId"); + }); + + modelBuilder.Entity("Yavsc.Models.Contact", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("OwnerId"); + }); + + modelBuilder.Entity("Yavsc.Models.Identity.GoogleCloudMobileDeclaration", b => + { + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("DeviceOwnerId"); + }); + + modelBuilder.Entity("Yavsc.Models.Market.Service", b => + { + b.HasOne("Yavsc.Models.Activity") + .WithMany() + .HasForeignKey("ContextId"); + }); + + modelBuilder.Entity("Yavsc.Models.PostTag", b => + { + b.HasOne("Yavsc.Models.Blog") + .WithMany() + .HasForeignKey("PostId"); + }); + + modelBuilder.Entity("Yavsc.Models.Workflow.PerformerProfile", b => + { + b.HasOne("Yavsc.Models.Activity") + .WithMany() + .HasForeignKey("ActivityCode"); + + b.HasOne("Yavsc.Models.Market.Service") + .WithMany() + .HasForeignKey("OfferId"); + + b.HasOne("Yavsc.Location") + .WithMany() + .HasForeignKey("OrganizationAddressId"); + + b.HasOne("Yavsc.Models.ApplicationUser") + .WithMany() + .HasForeignKey("PerformerId"); + }); + } + } +} diff --git a/Yavsc/Migrations/20160905095708_tags.cs b/Yavsc/Migrations/20160905095708_tags.cs new file mode 100644 index 00000000..6a29f033 --- /dev/null +++ b/Yavsc/Migrations/20160905095708_tags.cs @@ -0,0 +1,309 @@ +using System; +using System.Collections.Generic; +using Microsoft.Data.Entity.Migrations; + +namespace Yavsc.Migrations +{ + public partial class tags : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim_IdentityRole_RoleId", table: "AspNetRoleClaims"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim_ApplicationUser_UserId", table: "AspNetUserClaims"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin_ApplicationUser_UserId", table: "AspNetUserLogins"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole_IdentityRole_RoleId", table: "AspNetUserRoles"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole_ApplicationUser_UserId", table: "AspNetUserRoles"); + migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance"); + migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact"); + migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery"); + migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery"); + migrationBuilder.DropForeignKey(name: "FK_Circle_ApplicationUser_OwnerId", table: "Circle"); + migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember"); + migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember"); + migrationBuilder.DropForeignKey(name: "FK_Contact_ApplicationUser_OwnerId", table: "Contact"); + migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Activity_ActivityCode", table: "PerformerProfile"); + migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile"); + migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile"); + migrationBuilder.CreateTable( + name: "PostTag", + columns: table => new + { + PostId = table.Column(nullable: false), + TagId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PostTag", x => new { x.PostId, x.TagId }); + table.ForeignKey( + name: "FK_PostTag_Blog_PostId", + column: x => x.PostId, + principalTable: "Blog", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( + name: "Tag", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Npgsql:Serial", true), + Name = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Tag", x => x.Id); + }); + migrationBuilder.AddColumn( + name: "ApplicationUserId", + table: "Circle", + nullable: true); + migrationBuilder.AddForeignKey( + name: "FK_IdentityRoleClaim_IdentityRole_RoleId", + table: "AspNetRoleClaims", + column: "RoleId", + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserClaim_ApplicationUser_UserId", + table: "AspNetUserClaims", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserLogin_ApplicationUser_UserId", + table: "AspNetUserLogins", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserRole_IdentityRole_RoleId", + table: "AspNetUserRoles", + column: "RoleId", + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserRole_ApplicationUser_UserId", + table: "AspNetUserRoles", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_AccountBalance_ApplicationUser_UserId", + table: "AccountBalance", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_BalanceImpact_AccountBalance_BalanceId", + table: "BalanceImpact", + column: "BalanceId", + principalTable: "AccountBalance", + principalColumn: "UserId", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_BookQuery_ApplicationUser_ClientId", + table: "BookQuery", + column: "ClientId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_BookQuery_PerformerProfile_PerformerId", + table: "BookQuery", + column: "PerformerId", + principalTable: "PerformerProfile", + principalColumn: "PerformerId", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_Circle_ApplicationUser_ApplicationUserId", + table: "Circle", + column: "ApplicationUserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_CircleMember_Circle_CircleId", + table: "CircleMember", + column: "CircleId", + principalTable: "Circle", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_CircleMember_ApplicationUser_MemberId", + table: "CircleMember", + column: "MemberId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_Contact_ApplicationUser_OwnerId", + table: "Contact", + column: "OwnerId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_PerformerProfile_Activity_ActivityCode", + table: "PerformerProfile", + column: "ActivityCode", + principalTable: "Activity", + principalColumn: "Code", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_PerformerProfile_Location_OrganizationAddressId", + table: "PerformerProfile", + column: "OrganizationAddressId", + principalTable: "Location", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + migrationBuilder.AddForeignKey( + name: "FK_PerformerProfile_ApplicationUser_PerformerId", + table: "PerformerProfile", + column: "PerformerId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim_IdentityRole_RoleId", table: "AspNetRoleClaims"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim_ApplicationUser_UserId", table: "AspNetUserClaims"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin_ApplicationUser_UserId", table: "AspNetUserLogins"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole_IdentityRole_RoleId", table: "AspNetUserRoles"); + migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole_ApplicationUser_UserId", table: "AspNetUserRoles"); + migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance"); + migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact"); + migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery"); + migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery"); + migrationBuilder.DropForeignKey(name: "FK_Circle_ApplicationUser_ApplicationUserId", table: "Circle"); + migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember"); + migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember"); + migrationBuilder.DropForeignKey(name: "FK_Contact_ApplicationUser_OwnerId", table: "Contact"); + migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Activity_ActivityCode", table: "PerformerProfile"); + migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile"); + migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile"); + migrationBuilder.DropColumn(name: "ApplicationUserId", table: "Circle"); + migrationBuilder.DropTable("PostTag"); + migrationBuilder.DropTable("Tag"); + migrationBuilder.AddForeignKey( + name: "FK_IdentityRoleClaim_IdentityRole_RoleId", + table: "AspNetRoleClaims", + column: "RoleId", + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserClaim_ApplicationUser_UserId", + table: "AspNetUserClaims", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserLogin_ApplicationUser_UserId", + table: "AspNetUserLogins", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserRole_IdentityRole_RoleId", + table: "AspNetUserRoles", + column: "RoleId", + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_IdentityUserRole_ApplicationUser_UserId", + table: "AspNetUserRoles", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_AccountBalance_ApplicationUser_UserId", + table: "AccountBalance", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_BalanceImpact_AccountBalance_BalanceId", + table: "BalanceImpact", + column: "BalanceId", + principalTable: "AccountBalance", + principalColumn: "UserId", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_BookQuery_ApplicationUser_ClientId", + table: "BookQuery", + column: "ClientId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_BookQuery_PerformerProfile_PerformerId", + table: "BookQuery", + column: "PerformerId", + principalTable: "PerformerProfile", + principalColumn: "PerformerId", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_Circle_ApplicationUser_OwnerId", + table: "Circle", + column: "OwnerId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_CircleMember_Circle_CircleId", + table: "CircleMember", + column: "CircleId", + principalTable: "Circle", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_CircleMember_ApplicationUser_MemberId", + table: "CircleMember", + column: "MemberId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_Contact_ApplicationUser_OwnerId", + table: "Contact", + column: "OwnerId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_PerformerProfile_Activity_ActivityCode", + table: "PerformerProfile", + column: "ActivityCode", + principalTable: "Activity", + principalColumn: "Code", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_PerformerProfile_Location_OrganizationAddressId", + table: "PerformerProfile", + column: "OrganizationAddressId", + principalTable: "Location", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_PerformerProfile_ApplicationUser_PerformerId", + table: "PerformerProfile", + column: "PerformerId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs b/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs index 11f18eb8..806f014a 100644 --- a/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Yavsc/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,6 +1,8 @@ using System; using Microsoft.Data.Entity; using Microsoft.Data.Entity.Infrastructure; +using Microsoft.Data.Entity.Metadata; +using Microsoft.Data.Entity.Migrations; using Yavsc.Models; namespace Yavsc.Migrations @@ -367,6 +369,8 @@ namespace Yavsc.Migrations b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("ApplicationUserId"); + b.Property("Name"); b.Property("OwnerId"); @@ -379,8 +383,7 @@ namespace Yavsc.Migrations b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("CircleId") - .IsRequired(); + b.Property("CircleId"); b.Property("MemberId") .IsRequired(); @@ -473,6 +476,15 @@ namespace Yavsc.Migrations b.HasKey("UserId"); }); + modelBuilder.Entity("Yavsc.Models.PostTag", b => + { + b.Property("PostId"); + + b.Property("TagId"); + + b.HasKey("PostId", "TagId"); + }); + modelBuilder.Entity("Yavsc.Models.Skill", b => { b.Property("Id") @@ -485,6 +497,17 @@ namespace Yavsc.Migrations b.HasKey("Id"); }); + modelBuilder.Entity("Yavsc.Models.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired(); + + b.HasKey("Id"); + }); + modelBuilder.Entity("Yavsc.Models.Workflow.PerformerProfile", b => { b.Property("PerformerId"); @@ -637,7 +660,7 @@ namespace Yavsc.Migrations { b.HasOne("Yavsc.Models.ApplicationUser") .WithMany() - .HasForeignKey("OwnerId"); + .HasForeignKey("ApplicationUserId"); }); modelBuilder.Entity("Yavsc.Models.CircleMember", b => @@ -672,6 +695,13 @@ namespace Yavsc.Migrations .HasForeignKey("ContextId"); }); + modelBuilder.Entity("Yavsc.Models.PostTag", b => + { + b.HasOne("Yavsc.Models.Blog") + .WithMany() + .HasForeignKey("PostId"); + }); + modelBuilder.Entity("Yavsc.Models.Workflow.PerformerProfile", b => { b.HasOne("Yavsc.Models.Activity") diff --git a/Yavsc/Model/ApplicationDbContext.cs b/Yavsc/Model/ApplicationDbContext.cs index 2ca91bc8..e0cd5194 100644 --- a/Yavsc/Model/ApplicationDbContext.cs +++ b/Yavsc/Model/ApplicationDbContext.cs @@ -178,5 +178,9 @@ namespace Yavsc.Models public DbSet Tags { get; set; } public DbSet TagsDomain { get; set; } + + public DbSet EstimateTemplates { get; set; } + + } } diff --git a/Yavsc/Model/Billing/EstimateTemplate.cs b/Yavsc/Model/Billing/EstimateTemplate.cs new file mode 100644 index 00000000..d191f9d7 --- /dev/null +++ b/Yavsc/Model/Billing/EstimateTemplate.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Yavsc.Models.Billing +{ + public partial class EstimateTemplate + { + + [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long Id { get; set; } + public string Description { get; set; } + public string Title { get; set; } + public List Bill { get; set; } + + [Required] + public string OwnerId { get; set; } + } + +} \ No newline at end of file diff --git a/Yavsc/Model/Billing/NominatvieCommand.cs b/Yavsc/Model/Billing/NominatvieCommand.cs index 116e2f51..76b235de 100644 --- a/Yavsc/Model/Billing/NominatvieCommand.cs +++ b/Yavsc/Model/Billing/NominatvieCommand.cs @@ -40,7 +40,7 @@ namespace Yavsc.Models.Billing /// The bill /// /// - public List Bill { get; set; } + public List Bill { get; set; } = new List(); /// /// Time span in seconds in which diff --git a/Yavsc/Model/Booking/BookQuery.cs b/Yavsc/Model/Booking/BookQuery.cs index 63d1be3b..b8f787c8 100644 --- a/Yavsc/Model/Booking/BookQuery.cs +++ b/Yavsc/Model/Booking/BookQuery.cs @@ -17,18 +17,27 @@ namespace Yavsc.Models.Booking public long Id {get; set; } [Display(Name="Event date")] - public DateTime EventDate{get; set; } - public Location Location { get; set; } + public DateTime EventDate{ + get + { return ((RendezVous)Bill[0]).EventDate; } + set { ((RendezVous)Bill[0]).EventDate = value; } + } + public Location Location { + get + { return ((RendezVous)Bill[0]).Location; } + set { ((RendezVous)Bill[0]).Location = value; }} public BookQuery() { - + this.Bill.Add(new RendezVous()); } public BookQuery(Location eventLocation, DateTime eventDate) { - Location = eventLocation; - EventDate = eventDate; + this.Bill.Add(new RendezVous{ + Location = eventLocation, + EventDate = eventDate + }); } public string GetDescription() { return $"{Location?.Address} {EventDate.ToString()}"; diff --git a/Yavsc/Model/Market/Service.cs b/Yavsc/Model/Market/Service.cs index 11ce67af..4d116294 100644 --- a/Yavsc/Model/Market/Service.cs +++ b/Yavsc/Model/Market/Service.cs @@ -2,6 +2,7 @@ namespace Yavsc.Models.Market { using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; + using Billing; public partial class Service : BaseProduct {