예제 #1
0
        public async Task <string> CreateListing(Listing listing)
        {
            if (listing.Comment != null)
            {
                listing.Comment = WebUtility.HtmlDecode(listing.Comment).Replace("+", " ");
            }
            listing.PickupAddress = WebUtility.HtmlDecode(listing.PickupAddress).Replace("+", " ");
            //If product is not set to null the product will be added to db twice
            listing.Product = null;
            EntityEntry <Listing> newlyAdded = await ctx.listings.AddAsync(listing);

            await ctx.SaveChangesAsync();

            return(newlyAdded.Entity.ListingId + "");
        }
예제 #2
0
        public async Task <string> CreateUserAsync(User user)
        {
            EntityEntry <User> newlyAdded = await ctx.Users.AddAsync(user);

            await ctx.SaveChangesAsync();

            return(newlyAdded.Entity.UserId + "");
        }
예제 #3
0
        public async Task <string> CreateListingReport(Report report)
        {
            EntityEntry <Report> newlyAdded = await ctx.Reports.AddAsync(report);

            await ctx.SaveChangesAsync();

            return(newlyAdded.Entity.ReportId + "");
        }
예제 #4
0
        public async Task <string> CreateCompany(Company company)
        {
            bool alreadyExists = ctx.Companies.Any(c => c.Cvr == company.Cvr);

            if (alreadyExists)
            {
                return("alreadyExists");
            }
            else
            {
                company.Name    = WebUtility.HtmlDecode(company.Name).Replace("+", " ");
                company.Address = WebUtility.HtmlDecode(company.Address).Replace("+", " ");
                EntityEntry <Company> newlyAdded = await ctx.Companies.AddAsync(company);

                await ctx.SaveChangesAsync();

                return(newlyAdded.Entity.CompanyId + "");
            }
        }