public async Task <IHttpActionResult> GetSupplyContract(int Id)
        {
            SupplyContract supplyContract = await _db.SupplyContracts.SingleOrDefaultAsync(i => i.Id == Id);

            if (supplyContract == null)
            {
                return(NotFound());
            }

            return(Ok(supplyContract));
        }
Beispiel #2
0
        public void AddSupplyContractLink(GetSupplyContract link)
        {
            Supply         defaultSupply   = db.Supplies.Include(data => data.Contract).Include(data => data.Organization).FirstOrDefault(data => data.Id == link.SupplyId);
            Contract       defaultContract = db.Contracts.Include(data => data.Employe).Include(data => data.Supply).FirstOrDefault(data => (/*data.Supply == null && data.Employe != null*/ data.Id == link.Contractid));
            SupplyContract SC = new SupplyContract()
            {
                ContractId = defaultContract.Id, SupplyId = defaultSupply.Id
            };

            defaultSupply.Contract        = SC;
            db.Entry(defaultSupply).State = EntityState.Modified;
            db.SaveChanges();
        }
Beispiel #3
0
 public DbService(DataContext dataContext)
 {
     db = dataContext;
     if (!db.Employers.Any())
     {
         db.Employers.Add(new Employe()
         {
             EmployeFullName = "Solovyov Andrey Uladimiravich", DepartamentId = "IT", Qualification = "Engeneer", MoneyProfit = 100, Premials = 10, Month = "October"
         });
         db.Organizations.Add(new Organization()
         {
             Adress = "Test adress", Sity = "N", CountryCode = 555, Phone = "555-35-35", Email = "*****@*****.**"
         });
         db.Supplies.Add(new Supply()
         {
             HardwareType = "IBM PC", UsersReview = "None"
         });
         db.Contracts.Add(new Contract());
         db.SaveChanges();
         Employe          defaultEmploye      = db.Employers.Include(data => data.Contracts).FirstOrDefault();
         Contract         defaultContract     = db.Contracts.Include(data => data.Employe).Include(data => data.Supply).FirstOrDefault();
         Organization     defaultOrganization = db.Organizations.Include(data => data.Supply).FirstOrDefault();
         Supply           defaultSupply       = db.Supplies.Include(data => data.Organization).Include(data => data.Contract).FirstOrDefault();
         ContractsEmploye CElink = new ContractsEmploye()
         {
             ContractId = defaultContract.Id, EmployeId = defaultEmploye.Id
         };
         SupplyContract SClink = new SupplyContract()
         {
             ContractId = defaultContract.Id, SupplyId = defaultSupply.Id
         };
         SupplyOrganizations SOlink = new SupplyOrganizations()
         {
             SupplyId = defaultSupply.Id, OrganizationId = defaultOrganization.Id
         };
         defaultEmploye.Contracts.Add(CElink);
         defaultContract.Supply = SClink;
         defaultSupply.Organization.Add(SOlink);
         ///modify
         db.Entry(defaultEmploye).State  = EntityState.Modified; //look for mistakes
         db.Entry(defaultContract).State = EntityState.Modified; //
         db.Entry(defaultSupply).State   = EntityState.Modified; //
         db.SaveChanges();
     }
 }
Beispiel #4
0
    public Contract GetContractForShop()
    {
        Contract c;
        if(isDelivery)
        {
            c = new DeliveryContract();
        }
        else
        {
            c = new SupplyContract();
        }
        c.Crate = new Crate();
        int numFeatures = RandomEx.RandomIndexWeighted(sizeWeights) + 1;
        for(int i = 0; i < numFeatures; i++)
        {
            c.Crate.Features.Add(CrateFeature.RandomNonWild());
        }

        c.Quantity = Random.Range(1,20)*50;

        return c;
    }