Inheritance: ExtensibleDataObject
        public bool CreateBidRequest(CreateBidRequestViewModel requestModel)
        {
            var dev     = freelancerDb.Developers.FirstOrDefault(t => t.DeveloperId == requestModel.DeveloperId);
            var project = freelancerDb.Projects.FirstOrDefault(t => t.ProjectId == requestModel.ProjectId);

            if (dev == null || project == null)
            {
                return(false);
            }

            var isExist = freelancerDb.BidRequests.Any(t => t.Developer.DeveloperId == requestModel.DeveloperId && t.Project.ProjectId == requestModel.ProjectId);

            if (isExist)
            {
                return(false);
            }

            var bidRequest = new BidRequest
            {
                BidRequestId  = Guid.NewGuid().ToString(),
                CreationDate  = DateTime.Now,
                Developer     = dev,
                Project       = project,
                Note          = requestModel.Note,
                Price         = Convert.ToDouble(requestModel.Price),
                DaysToFinish  = requestModel.DaysToFinish,
                RequestStatus = RequestStatus.Pending
            };

            freelancerDb.BidRequests.Add(bidRequest);
            freelancerDb.SaveChanges();
            return(true);
        }
        public IActionResult DeleteBidReq(int bidrequestID)
        {
            BidRequest deletedBR = bidReqRepo.DeleteBR(bidrequestID);

            if (deletedBR == null)
            {
                return(RedirectToAction("Index", "Error"));
            }
            return(RedirectToAction("AdminPage", "Admin"));
        }
示例#3
0
        public BidRequest DeleteBR(int id)
        {
            BidRequest bReq = context.BidRequests.FirstOrDefault(br => br.BidRequestID == id);

            if (bReq != null)
            {
                context.BidRequests.Remove(bReq);
                context.SaveChanges();
            }
            return(bReq);
        }
    public void OnBidItem(int id)
    {
        BidRequest request = new BidRequest();

        request.OfferId  = id;
        request.ChatId   = m_iChatId;
        m_BuyerBidItemId = id;
        AsyncBidRequest async = new AsyncBidRequest(request);

        async.TryRequest();
    }
        public ViewResult Bid(int bidrequestID)
        {
            //passing bid request info to the view
            BidRequest br    = bidReqRepo.GetBidRequestByID(bidrequestID);
            VMBid      vmbid = new VMBid();

            vmbid.BidRequestID       = bidrequestID;
            vmbid.CustomerFirst      = br.User.FirstName;
            vmbid.CustomerLast       = br.User.LastName;
            vmbid.ProjectDescription = br.ProjectDescription;
            return(View(vmbid));
        }
示例#6
0
        public async Task <string> AcceptBidAsync(int proId, string userId, int price)
        {
            var message = string.Empty;



            var bidProduct = await _db.BidRequests.Where(p => p.ProductId == proId && p.UserId == userId).ToListAsync();

            if (bidProduct.Count() == 0)
            {
                var bidRequest = new BidRequest
                {
                    ProductId = proId,
                    Price     = price,
                    UserId    = userId,
                    BidDate   = DateTime.Now,
                    BidTimes  = 1
                };



                _db.BidRequests.Add(bidRequest);
            }



            else if (bidProduct.Count() == 1)
            {
                var bidRequest = new BidRequest
                {
                    ProductId = proId,
                    Price     = price,
                    UserId    = userId,
                    BidDate   = DateTime.Now,
                    BidTimes  = 2
                };
                _db.BidRequests.Add(bidRequest);
            }



            else
            {
                message = "More than 2 bids";
            }



            await _db.SaveChangesAsync();


            return(message);
        }
示例#7
0
        public ActionResult Deletereq(int id)
        {
            BidRequest bdr = db.requests.Find(id);

            if (bdr != null)
            {
                db.requests.Remove(bdr);
                db.SaveChanges();
            }

            return(RedirectToAction("Table"));
        }
        public async Task <Guid> Add(BidRequest entity)
        {
            try
            {
                var result = await unitOfWork.GetConnection().QueryFirstAsync <Guid>(AddSql, entity, unitOfWork.GetTransaction());

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#9
0
        public int Update(BidRequest req)
        {
            if (req.BidRequestID == 0)
            {
                context.BidRequests.Add(req);
            }
            else
            {
                context.BidRequests.Update(req);
            }

            return(context.SaveChanges());
        }
示例#10
0
        public bool UniqueEmail(string email)
        {
            BidRequest br = context.BidRequests.FirstOrDefault(r => r.User.Email == email);

            if (br == null)
            {
                return(false); //no user with that email in the db
            }
            else
            {
                return(true);
            }
        }
        public override async Task <BidResponse> Bid(BidRequest request, ServerCallContext context)
        {
            Guid auctionId;

            if (!Guid.TryParse(request.AuctionId, out auctionId))
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "auctionid is not a guid"));
            }
            var auction = _auctionService.GetAuction(auctionId);

            if (auction == null)
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "auction not found"));
            }

            var expiry = (auction.Duration + auction.StartedAt) - Utility.Utility.DateTimeToUnix(DateTime.UtcNow);

            if (auction.FinishedAt != 0 || expiry < 5)
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "auction is already finished"));
            }
            if (request.Amount < 1)
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "amount must be larger than 0"));
            }
            if (request.Message.Length > 140)
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "message must be smaller than 140 characters"));
            }
            var entry = await _auctionService.RequestAuctionEntryInvoice(auctionId, request.Amount, request.Message);

            if (entry == null)
            {
                throw new RpcException(new Status(StatusCode.Internal, "something went wrong..."));
            }
            var res = new BidResponse
            {
                Entry = new AuctionEntry
                {
                    Amount         = entry.Amount,
                    Description    = entry.Description,
                    Id             = entry.Id.ToString(),
                    Message        = entry.Message,
                    PaymentRequest = entry.PaymentRequest,
                    State          = (AuctionEntry.Types.State)((int)entry.State)
                }
            };

            return(res);
        }
示例#12
0
            public async Task <BaseResponses <ProjectBidRequestDTO> > Handle(ProjectCommentRequest request, CancellationToken cancellationToken)
            {
                BaseResponses <ProjectBidRequestDTO> response = null;

                using (var trx = unitOfWork.BeginTransaction())
                {
                    try
                    {
                        if (request.Comment != null)
                        {
                            var user1 = userManager.FindByNameAsync(request.FreekancerName);
                            //ApplicationUser appuser = new ApplicationUser();
                            //appuser = user1.Result;
                            BidRequest bid = new BidRequest();
                            bid.BidPrice     = request.BidPrice;
                            bid.Comment      = request.Comment;
                            bid.ProjectId    = request.ProjectID.ToString();
                            bid.FreelancerId = user1.Result.Id;
                            await bidRequestService.Add(bid);
                        }
                        var project = await projectService.GetById(request.ProjectID.ToString());

                        var bidRequests = await bidRequestService.GetBidRequestsByProjectId(request.ProjectID.ToString());

                        var projectDetailsDTO = new ProjectBidRequestDTO()
                        {
                            Project = project
                        };
                        foreach (var item in bidRequests)
                        {
                            var user = await userManager.FindByIdAsync(item.FreelancerId.ToString());

                            projectDetailsDTO.BidRequests.Add(
                                new BidRequestDTO {
                                BidRequest = item,
                                FreeLancer = user
                            });
                        }
                        unitOfWork.SaveChanges();
                        response = new BaseResponses <ProjectBidRequestDTO>(projectDetailsDTO);
                    }
                    catch (RestException ex)
                    {
                        trx.Rollback();
                        response = new BaseResponses <ProjectBidRequestDTO>(ex.StatusCode, ex.Message);
                    }
                    return(response);
                }
            }
示例#13
0
        public async Task <BidRequest> Add(BidRequest entity)
        {
            try
            {
                var addedId = await bidRequestRepository.Add(entity);

                var result = await bidRequestRepository.GetById(addedId.ToString());

                return(result);
            }
            catch (Exception ex)
            {
                throw new RestException(System.Net.HttpStatusCode.NotFound, ex.Message);
            }
        }
        public ActionResult RequestForBid(String pn, String sd, String mbp, String bti, String fn, HttpPostedFileBase image)
        {
            BidRequest bdr = new BidRequest();

            if (Request.Form["submit"] != null)
            {
                try
                {
                    bdr.ImageData = new byte[image.ContentLength];
                    image.InputStream.Read(bdr.ImageData, 0, image.ContentLength);
                    bdr.ProductName = pn;
                    bdr.Details     = sd;
                    double bp = double.Parse(mbp);
                    bdr.BasePrice = bp;

                    int bt = Int32.Parse(bti);
                    bdr.MaxTime  = bt;
                    bdr.FileName = fn;
                    string buyer = (string)(Session["log"]);
                    bdr.SellerName = buyer;
                    db.requests.Add(bdr);
                    db.SaveChanges();
                    ibc = 1;
                }
                catch (DbEntityValidationException e)
                {
                    ViewBag.error1 = 1;
                    return(View());

                    StringBuilder sb = new StringBuilder();
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                    eve.Entry.Entity.GetType().Name,
                                                    eve.Entry.State));
                        foreach (var ve in eve.ValidationErrors)
                        {
                            sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                        ve.PropertyName,
                                                        ve.ErrorMessage));
                        }
                    }
                    throw new DbEntityValidationException(sb.ToString(), e);
                }
            }
            return(RedirectToAction("Index"));
        }
        public async Task <bool> BidOnAuction(List <Bid> bids)
        {
            var bidRequest = new BidRequest(bids);

            using (var client = InitializeHttpClientWithAccessToken(AccessToken))
            {
                HttpResponseMessage bidResponse = await client.PostAsJsonAsync("api/v1/bid", bidRequest);

                if (bidResponse.StatusCode == HttpStatusCode.Accepted)
                {
                    return(true);
                }
                else
                {
                    Logger.LogError("Bid Request failed, Reason : " + await bidResponse.Content.ReadAsStringAsync());
                }
                return(false);
            }
        }
        public async Task <IActionResult> PlaceBid(BidSent newBid)
        {
            IDbContextTransaction transaction = _context.Database.BeginTransaction();

            try
            {
                var user = _context.Users.FirstOrDefault(u => u.UserId == newBid.RequestUsersId);

                newBid.BidDate = DateTime.Now;
                _context.Add(newBid);
                await _context.SaveChangesAsync();

                var lastBidReq = await _context.BidsSent.OrderByDescending(x => x.Id).FirstOrDefaultAsync();

                BidRequest bidReq = new BidRequest
                {
                    UserId          = newBid.UserId,
                    BidSentId       = lastBidReq.Id,
                    BidStatus       = newBid.BidStatus,
                    BidCoins        = newBid.BidCoins,
                    BidType         = newBid.BidCoinsType,
                    BidderName      = $"{user.Firstname} {user.Lastname}",
                    BidderCellphone = user.Cellphone,
                    RecipientName   = newBid.RecipientName,
                    BidDate         = DateTime.Now
                };

                _context.Add(bidReq);
                await _context.SaveChangesAsync();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            return(RedirectToAction(nameof(Dashboard)));
        }
 public Task Update(BidRequest entity)
 {
     throw new NotImplementedException();
 }
示例#18
0
        public ActionResult Display([FromBody] BidRequest bidRequest)
        {
            // primary logic
            if (bidRequest is null || bidRequest.id is null || bidRequest.id == "")
            {
                return(StatusCode(404));
            }

            // secondary logic
            // this is where we may want to check on things like keywords, context, etc...


            if (_kdbConnectorOptions.TestMode)
            {
                // return test bid
                var bid = new Models.BidResponseViewModels.Bid()
                {
                    adomain = new string[] { "mrpfd.com" },
                    attr    = new int[] { 1, 2, 3, 4, 5, 6, 7 },
                    cid     = "campaign123",
                    crid    = "creative123",
                    id      = bidRequest.id,
                    impid   = "102",
                    iurl    = "https://adserver.com/winnotice?impid=102",
                    nurl    = "https://adserver.com/pathtosampleimage",
                    price   = 9.55f
                };

                var seatbid = new Models.BidResponseViewModels.SeatBid()
                {
                    bid  = new Models.BidResponseViewModels.Bid[] { bid },
                    seat = "mrpfdseatid"
                };

                var response = new Models.BidResponseViewModels.BidResponse()
                {
                    bidid   = "mrpfd1234567",
                    cur     = "USD",
                    id      = bidRequest.id,
                    seatbid = new Models.BidResponseViewModels.SeatBid[] { seatbid }
                };

                return(new JsonResult(response));
            }
            else
            {
                // submit bid to kdb by passing a disctionary object
                // we're using the qsharp library, documentation here: https://github.com/exxeleron/qSharp/blob/master/doc/Readme.md
                // TO DO: Not sure the library does connection pooling and this sample will open connections to Kdb with every bid
                // need to see how to reuse existing connections, perhaps by creating connections at startup and passing via dependency injection


                _logger.LogInformation("Bid received: {1}", JsonConvert.SerializeObject(bidRequest));

                var qbidKeys   = new List <String>();
                var qbidValues = new List <Object>();


                qbidKeys.Add("id");
                qbidValues.Add(bidRequest.id);

                qbidKeys.Add("time");
                qbidValues.Add(new QDateTime(DateTime.Now));


                qbidKeys.Add("ip");
                qbidValues.Add(bidRequest.device.ip);


                qbidKeys.Add("ua");
                qbidValues.Add(bidRequest.device.ua);


                qbidKeys.Add("urls");
                qbidValues.Add(bidRequest.site.page);


                qbidKeys.Add("ex");
                qbidValues.Add("TEST");


                qbidKeys.Add("UserID");
                qbidValues.Add(bidRequest.user.id);


                qbidKeys.Add("uid");
                qbidValues.Add(bidRequest.user.buyeruid);


                qbidKeys.Add("bidfloor");
                qbidValues.Add(bidRequest.imp.First().bidfloor);


                qbidKeys.Add("isTest");
                qbidValues.Add(_kdbConnectorOptions.TestMode);


                qbidKeys.Add("at");
                qbidValues.Add(bidRequest.at);


                qbidKeys.Add("w");
                qbidValues.Add(bidRequest.imp.First().banner.w);


                qbidKeys.Add("h");
                qbidValues.Add(bidRequest.imp.First().banner.h);


                qbidKeys.Add("cat");
                qbidValues.Add(bidRequest.site.cat.FirstOrDefault());


                qbidKeys.Add("devcountry");
                qbidValues.Add(bidRequest.device.geo.country);


                qbidKeys.Add("devregion");
                qbidValues.Add(bidRequest.device.geo.region);


                qbidKeys.Add("devcity");
                qbidValues.Add(bidRequest.device.geo.city);


                qbidKeys.Add("regsGDPR");
                qbidValues.Add("");


                qbidKeys.Add("iabGDPR");
                qbidValues.Add("");


                qbidKeys.Add("consentedVendors");
                qbidValues.Add("");


                qbidKeys.Add("json");
                qbidValues.Add(JsonConvert.SerializeObject(bidRequest));


                try
                {
                    // check if connection is lost need to reconnect
                    if (!_qConnection.IsConnected())
                    {
                        _qConnection.Reset();
                        _logger.LogInformation("Connection to kdb was reset");
                    }

                    var qBidResponse = (QDictionary)_qConnection.Sync(".dmc_bidder.upd_bidRequest", new QDictionary(qbidKeys.ToArray(), qbidValues.ToArray()));


                    // marshall values back into bidResponse

                    var bid = new Models.BidResponseViewModels.Bid()
                    {
                    };
                    var seat = "";

                    foreach (var kvp in qBidResponse)
                    {
                        switch (kvp.Key)
                        {
                        case "w":
                            bid.w = (Int16)kvp.Value;
                            break;

                        case "h":
                            bid.h = (Int16)kvp.Value;
                            break;

                        case "bid":
                            bid.price = Convert.ToSingle((Double)kvp.Value);
                            break;

                        case "ad":
                            bid.adm = new string((char[])kvp.Value);
                            break;

                        case "cid":
                            bid.cid = new string((char[])kvp.Value);
                            break;

                        case "burl":
                            bid.nurl = new string((char[])kvp.Value);
                            break;

                        case "crid":
                            bid.crid = new string((char[])kvp.Value);
                            break;

                        case "iurl":
                            bid.iurl = new string((char[])kvp.Value);
                            break;

                        case "adomain":
                            bid.adomain = new string[] { new string((char[])kvp.Value) };
                            break;

                        case "seat":
                            seat = new string((char[])kvp.Value);
                            break;

                        default:
                            break;
                        }
                        ;
                    }


                    var seatbid = new Models.BidResponseViewModels.SeatBid()
                    {
                        bid  = new Models.BidResponseViewModels.Bid[] { bid },
                        seat = seat
                    };

                    var response = new Models.BidResponseViewModels.BidResponse()
                    {
                        bidid   = "mrpfd1234567",
                        cur     = "USD",
                        id      = bidRequest.id,
                        seatbid = new Models.BidResponseViewModels.SeatBid[] { seatbid }
                    };

                    _logger.LogInformation("Bid response: {1}", JsonConvert.SerializeObject(response));

                    return(new JsonResult(response));
                }
                catch (Exception e)
                {
                    Console.WriteLine("`" + e.Message);
                    if (e.Source == "System.Net.Sockets" && e.HResult == -2146232798)
                    {
                        // possibly lost connexion to socket - may want to try and reconnect
                        try
                        {
                            _logger.LogInformation("Attempting to reset connection to kdb");
                            _qConnection.Reset();
                            _logger.LogInformation("Connection to kdb was reset");
                        }
                        catch (Exception ex)
                        {
                            _logger.LogCritical("Could not re-establish connection to kdb");
                            // well if this doesn't work....
                        }
                    }
                    _logger.LogCritical("Feedhandler error: {1}", e.Message);
                    return(StatusCode(404));
                }
            }
        }
示例#19
0
 //[ActionName("Bid")]
 public ActionResult Bid([FromForm] BidRequest bid)
 {
     return(Ok(_biddings.Bid(bid)));
 }
示例#20
0
        public ActionResult postreq(Product product)
        {
            success = 0;
            int        count = db.products.Count();
            BidRequest bdr   = db.requests.Find(postreqid);

            if (ModelState.IsValid)
            {
                if (count < 13)
                {
                    if (bdr != null)
                    {
                        product.productID    = bdr.ProductName + postreqid;
                        product.ProductName  = bdr.ProductName;
                        product.Details      = bdr.Details;
                        product.FileName     = bdr.FileName;
                        product.ImageData    = bdr.ImageData;
                        product.BasePrice    = bdr.BasePrice;
                        product.BiddingPrice = bdr.BasePrice;
                        product.SellerName   = bdr.SellerName;
                        db.products.Add(product);
                        db.SaveChanges();
                        success = 1;

                        var r1 = db.alerts.Where(v => v.FavouriteCategory.Equals(product.Category));
                        foreach (var item1 in r1)
                        {
                            SmtpClient smtp1 = new SmtpClient(" smtp.gmail.com", 587);

                            smtp1.EnableSsl = true;
                            smtp1.Timeout   = 100000;

                            smtp1.DeliveryMethod        = SmtpDeliveryMethod.Network;
                            smtp1.UseDefaultCredentials = false;

                            smtp1.Credentials = new NetworkCredential("*****@*****.**", "eauction 597");
                            MailMessage message1 = new MailMessage();

                            message1.To.Add(item1.Email);
                            message1.From    = new MailAddress("*****@*****.**");
                            message1.Subject = "LIVE BID!";
                            message1.Body    = "NEW product in" + item1.FavouriteCategory + " Section. Please Visit our website! ";


                            smtp1.Send(message1);
                        }
                        string a = null;
                        var    r = db.reg.Where(v => v.UserName.Equals(bdr.SellerName));
                        foreach (var item in r)
                        {
                            a = item.Email;
                        }


                        SmtpClient smtp = new SmtpClient(" smtp.gmail.com", 587);

                        smtp.EnableSsl = true;
                        smtp.Timeout   = 100000;

                        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        smtp.UseDefaultCredentials = false;

                        smtp.Credentials = new NetworkCredential("*****@*****.**", "eauction 597");
                        MailMessage message = new MailMessage();

                        message.To.Add(a);
                        message.From    = new MailAddress("*****@*****.**");
                        message.Subject = "LIVE BID!";
                        message.Body    = "Your product now in Live Auction. Please See Home of E-AUCTION for further confirmation.";


                        smtp.Send(message);
                        return(RedirectToAction("Table"));
                    }
                }
                else
                {
                    success = 2;

                    return(RedirectToAction("Table"));
                }
            }

            return(View(product));
        }
示例#21
0
        public static async Task EnsurePopulated(IApplicationBuilder app)
        {
            UserManager <UserIdentity> userManager = app.ApplicationServices.GetRequiredService <UserManager <UserIdentity> >();
            RoleManager <IdentityRole> roleManager = app.ApplicationServices.GetRequiredService <RoleManager <IdentityRole> >();
            ApplicationDbContext       context     = app.ApplicationServices.GetRequiredService <ApplicationDbContext>();

            if (!context.Reviews.Any())
            {
                UserIdentity user = new UserIdentity
                {
                    FirstName = "Henry",
                    LastName  = "Homes",
                    Email     = "*****@*****.**",
                    Password  = "******",
                    UserName  = "******"
                };

                string role = "User";
                await roleManager.CreateAsync(new IdentityRole(role));

                IdentityResult result = await userManager.CreateAsync(user, user.Password);

                await userManager.AddToRoleAsync(user, role);



                Client client = new Client
                {
                    FirstName    = "Henry",
                    LastName     = "Homes",
                    CompanyName  = "Murder Company Inc.",
                    Street       = "999 Elm Street",
                    City         = "Eugene",
                    State        = "OR",
                    Zipcode      = "97405",
                    PhoneNumber  = "(541) 548-9852",
                    Email        = "*****@*****.**",
                    UserIdentity = user
                };
                context.Clients.Add(client);

                BidRequest bidRequest = new BidRequest
                {
                    User               = user,
                    Concrete           = false,
                    FrameWork          = false,
                    NewBuild           = true,
                    ProjectDescription = "Big deck",
                    ProjectLocation    = "Lane county",
                    Remodel            = false
                };
                context.BidRequests.Add(bidRequest);

                Bid bid = new Bid
                {
                    ProposedStartDate         = DateTime.Now,
                    TotalEstimate             = 6548.06M,
                    RevisedProjectDescription = "Wood deck with railing",
                    BidReq = bidRequest,
                    User   = user
                };


                context.Bids.Add(bid);

                Project project1 = new Project
                {
                    Client           = client,
                    Bid              = bid,
                    ProjectName      = "Wood Deck",
                    OriginalEstimate = 6548.06M,
                    StartDate        = DateTime.Now,
                    ProjectStatus    = "Framing Complete",
                    StatusDate       = DateTime.Now,
                    AdditionalCosts  = 1.94M,
                    TotalCost        = 6550M
                };
                context.Projects.Add(project1);


                Review message = new Review
                {
                    Subject  = "Loved it!",
                    Body     = "it them a bit more time than I though it would be but it was worth the wait!!",
                    From     = user,
                    Approved = true,
                    Date     = new DateTime(2006, 8, 22),
                };

                context.Add(message);

                UserIdentity user2 = new UserIdentity
                {
                    FirstName = "Sherlock",
                    LastName  = "Homes",
                    Email     = "*****@*****.**",
                    Password  = "******",
                    UserName  = "******"
                };

                IdentityResult result2 = await userManager.CreateAsync(user2, user2.Password);

                await userManager.AddToRoleAsync(user2, role);

                //if (await roleManager.FindByNameAsync(role) == null)
                //{

                //    if (result2.Succeeded)
                //    {
                //        await userManager.AddToRoleAsync(user2, role);
                //    }
                //}
                //else
                //{
                //    await roleManager.CreateAsync(new IdentityRole(role));
                //    if (result2.Succeeded)
                //    {
                //        await userManager.AddToRoleAsync(user2, role);
                //    }
                //}

                Client client2 = new Client
                {
                    FirstName    = "Sherlock",
                    LastName     = "Homes",
                    CompanyName  = "Murder Company Inc.",
                    Street       = "999 Elm Street",
                    City         = "Eugene",
                    State        = "OR",
                    Zipcode      = "97405",
                    PhoneNumber  = "(541) 548-9852",
                    Email        = "*****@*****.**",
                    UserIdentity = user2
                };

                context.Clients.Add(client2);

                BidRequest bidRequest2 = new BidRequest
                {
                    User               = user2,
                    Concrete           = false,
                    FrameWork          = false,
                    NewBuild           = false,
                    ProjectDescription = "Remodel Bathroom",
                    ProjectLocation    = "Linn county",
                    Remodel            = true
                };
                context.BidRequests.Add(bidRequest2);

                Bid bid2 = new Bid
                {
                    ProposedStartDate         = DateTime.Now,
                    TotalEstimate             = 2058.06M,
                    RevisedProjectDescription = "Test bid for test project",
                    BidReq = bidRequest2,
                    User   = user2
                };

                context.Bids.Add(bid2);

                Project project2 = new Project
                {
                    Client           = client2,
                    Bid              = bid2,
                    ProjectName      = "Bathroom Remodel",
                    OriginalEstimate = 2058.06M,
                    StartDate        = DateTime.Now,
                    ProjectStatus    = "Started",
                    StatusDate       = DateTime.Now,
                    AdditionalCosts  = 2.94M,
                    TotalCost        = 2061.00M
                };
                context.Projects.Add(project2);

                UserIdentity user3 = new UserIdentity
                {
                    FirstName = "John",
                    LastName  = "Doe",
                    Email     = "*****@*****.**",
                    Password  = "******",
                    UserName  = "******"
                };

                IdentityResult result3 = await userManager.CreateAsync(user3, user3.Password);

                await userManager.AddToRoleAsync(user3, role);

                //if (await roleManager.FindByNameAsync(role) == null)
                //{
                //    await roleManager.CreateAsync(new IdentityRole(role));
                //    if (result.Succeeded)
                //    {
                //        await userManager.AddToRoleAsync(user2, role);
                //    }
                //}
                //else
                //{
                //    await roleManager.CreateAsync(new IdentityRole(role));
                //    if (result3.Succeeded)
                //    {
                //        await userManager.AddToRoleAsync(user2, role);
                //    }
                //}

                message = new Review
                {
                    Subject  = "Hated it!",
                    Body     = "it them a bit more time than I though and it was not worth it!!",
                    From     = user2,
                    Approved = false,
                    Date     = new DateTime(2010, 8, 10),
                };

                context.Add(message);



                /*this adds a test project to seeddata. this needs to create a
                 * client, bid and bidrequest in order to do so*/

                UserIdentity user4 = new UserIdentity
                {
                    FirstName = "Ricky",
                    LastName  = "Bobby",
                    Email     = "*****@*****.**",
                    Password  = "******",
                    UserName  = "******"
                };

                IdentityResult result4 = await userManager.CreateAsync(user4, user4.Password);

                await userManager.AddToRoleAsync(user4, role);

                UserIdentity user5 = new UserIdentity
                {
                    FirstName = "Blue",
                    LastName  = "Sue",
                    Email     = "*****@*****.**",
                    Password  = "******",
                    UserName  = "******"
                };


                await roleManager.CreateAsync(new IdentityRole(role));

                IdentityResult result5 = await userManager.CreateAsync(user5, user5.Password);

                await userManager.AddToRoleAsync(user5, role);

                ////finds user
                //UserIdentity bidUser = await userManager.FindByEmailAsync("*****@*****.**");

                ////creates bidrequest from
                //BidRequest bidReq3 = new BidRequest
                //{
                //    User = bidUser,
                //    Concrete = false,
                //    FrameWork = false,
                //    NewBuild = true,
                //    ProjectDescription = "Test bidrequest",
                //    ProjectLocation = "Your house",
                //    Remodel = false
                //};
                //context.BidRequests.Add(bidReq3);

                ////creates bid from user Henry Holmes
                //Bid bid3 = new Bid
                //{
                //    ProposedStartDate = DateTime.Now,
                //    TotalEstimate = 6548.06M,
                //    RevisedProjectDescription = "Test bid for test project",
                //    BidReq = bidReq3
                //};
                //bid.User = bidUser;
                ////if (bid.User != null)
                ////{
                //    context.Bids.Add(bid3);
                ////}

                ////creates client from Henry
                //Client client4 = new Client();
                //UserIdentity clientUser = bidUser;
                //client4.UserIdentity = clientUser;
                ////if (client.UserIdentity != null)
                ////{
                //    client4.FirstName = clientUser.FirstName;
                //    client4.LastName = clientUser.LastName;
                //    client4.Email = clientUser.Email;
                ////}
                ////else
                ////{
                ////    client.FirstName = "Ricky";
                ////    client.LastName = "Bobby";
                ////    //client.Email = "*****@*****.**";
                ////}
                //context.Clients.Add(client4);

                ////creates project
                //Project project = new Project
                //{
                //    Client = client4,
                //    Bid = bid3,
                //    ProjectName = "Test Project",
                //    OriginalEstimate = 6548.06M,
                //    StartDate = DateTime.Now,
                //    ProjectStatus = "Waiting for permit.",
                //    StatusDate = DateTime.Now,
                //    AdditionalCosts = 1.94M,
                //    TotalCost = 6550M
                //};
                //context.Projects.Add(project);

                context.SaveChanges();
            }
        }
示例#22
0
        //[Route("/{auctionId}/item/{itemId}/bid")]
        public async Task AddBidToAuctionItem(/*[FromUri]*/ string auctionId, /*[FromUri]*/ int itemId, [FromBody] BidRequest bidRequest)
        {
            //TODO: get ambient user info

            var bidCommand = new AddBidCommand("TODO: GET AMBIENT USER INFO", Guid.Parse(auctionId), itemId, bidRequest.Amount, DateTime.UtcNow);

            //Todo: dispatch command.
            await _mediator.Send(bidCommand);

            //Todo: read from read model the command results. {bidder,item,timestamp as key to lookup}
        }
示例#23
0
        // Post Methods
        /// <summary>
        /// <para>Performs the Bidding Method:
        /// Place a bid request.
        /// </para><para>
        /// Serializes the given BidRequest into xml and sends the message.
        /// </para>
        /// REQUIRES AUTHENTICATION.
        /// </summary>
        /// <param name="request">The object that will be serialized into xml and then sent in a POST message.</param>
        /// <returns>XDocument.</returns>
        public XDocument BidRequest(BidRequest request)
        {
            if (_bidding == null)
            {
                _bidding = new BiddingMethods(_connection);
            }

            return _bidding.BidRequest(request);
        }
        /// <summary>
        /// <para>Performs the Bidding Method:
        /// Place a bid request. POST
        /// </para><para>
        /// Serializes the given BidRequest into xml and sends the message.
        /// </para>
        /// REQUIRES AUTHENTICATION.
        /// </summary>
        /// <param name="request">The object that will be serialized into xml and then sent in a POST message.</param>
        /// <returns>XDocument: AuctionBidResponse</returns>
        public XDocument BidRequest(BidRequest request)
        {
            var query = String.Format(Constants.Culture, "{0}/Bid{1}", Constants.BIDDING, Constants.XML);

            return(_connection.Post(request, query));
        }
示例#25
0
 public bool Bid(BidRequest bid)
 {
     _context.Bids.Add(new BidEntity(bid));
     _context.SaveChanges();
     return(true);
 }
示例#26
0
        public string AddProjectBidRequest(string projectId)
        {
            var faker = new Bogus.Faker();

            var project = freelancerDb.Projects.FirstOrDefault(t => t.ProjectId == projectId);

            var user = new User
            {
                Id             = Guid.NewGuid().ToString(),
                UserName       = faker.Person.UserName,
                Email          = faker.Person.Email,
                Name           = faker.Person.FirstName,
                Surname        = faker.Person.LastName,
                ProfilePicture = faker.Person.Avatar,
                Country        = faker.Address.Country()
            };

            var developer = new Developer
            {
                DeveloperId = Guid.NewGuid().ToString(),
                Rating      = Convert.ToInt16(faker.Random.Int(1, 10)),
                RatingCount = Convert.ToInt16(faker.Random.Int(1, 10)),
                User        = user
            };

            developer.DeveloperSkill = new List <DeveloperSkill>
            {
                new DeveloperSkill
                {
                    Developer = developer,
                    Skill     = new Skill
                    {
                        SkillId = Guid.NewGuid().ToString(),
                        Name    = faker.Company.CompanySuffix()
                    }
                },
                new DeveloperSkill
                {
                    Developer = developer,
                    Skill     = new Skill
                    {
                        SkillId = Guid.NewGuid().ToString(),
                        Name    = faker.Company.CompanySuffix()
                    }
                },
                new DeveloperSkill
                {
                    Developer = developer,
                    Skill     = new Skill
                    {
                        SkillId = Guid.NewGuid().ToString(),
                        Name    = faker.Company.CompanySuffix()
                    }
                },
                new DeveloperSkill
                {
                    Developer = developer,
                    Skill     = new Skill
                    {
                        SkillId = Guid.NewGuid().ToString(),
                        Name    = faker.Company.CompanySuffix()
                    }
                }
            };

            var bidRequest = new BidRequest
            {
                BidRequestId  = Guid.NewGuid().ToString(),
                CreationDate  = faker.Date.Recent(),
                DaysToFinish  = faker.Random.Int(1, 300),
                Price         = faker.Random.Int(10, 1000),
                Project       = project,
                RequestStatus = RequestStatus.Pending,

                Note      = faker.Lorem.Sentences(),
                Developer = developer
            };

            freelancerDb.BidRequests.Add(bidRequest);
            freelancerDb.SaveChanges();
            return("Added");
        }
        public async Task <IActionResult> BidRequest(BidRequest bidreq)
        {
            //check to see if email is in the db
            if (!bidReqRepo.UniqueEmail(bidreq.User.Email)) //if false, its not in the database so it is a unique eamil
            {
                if (ModelState.IsValid)
                {
                    bidreq.User.UserName  = bidreq.User.Email;
                    bidreq.User.Email     = bidreq.User.Email;
                    bidreq.User.FirstName = bidreq.User.FirstName;
                    bidreq.User.LastName  = bidreq.User.LastName;
                    bidreq.DateCreated    = DateTime.Now;

                    IdentityResult result = await UserManager.CreateAsync(bidreq.User, bidreq.User.Password);

                    //if the user was successfully created
                    if (result.Succeeded)
                    {
                        //emailing the client to notify of request
                        var message = new MimeMessage();
                        message.From.Add(new MailboxAddress("MCCInc", Email));
                        message.To.Add(new MailboxAddress("MCCInc", Email));
                        message.Subject = "bid Request Requested";

                        message.Body = new TextPart("plain")
                        {
                            Text = @"Hey Admin, A new bid request was created please look at it and respond."
                        };

                        using (var client = new SmtpClient())
                        {
                            client.Connect(Server, Port);


                            client.Authenticate(Email, Password);

                            client.Send(message);

                            client.Disconnect(true);
                        }

                        //Here is where I send the confirmation link

                        /*string confirmationToken = UserManager.GenerateEmailConfirmationTokenAsync(bidreq.User).Result;
                         *
                         * string confirmationLink = Url.Action("ConfirmEmail", "Account", new { userid = bidreq.User.Id, token = confirmationToken }, protocol: HttpContext.Request.Scheme);
                         *
                         *
                         * var email = new MimeMessage();
                         * email.From.Add(new MailboxAddress("MCCInc", Email));
                         * email.Subject = "Confirm Email";
                         * email.Body = new TextPart("plain")
                         * {
                         *  Text = "Click the link to confirm your email " + confirmationLink
                         * };
                         * email.To.Add(new MailboxAddress(bidreq.User.Email));
                         *
                         * using (var client_c = new SmtpClient())
                         * {
                         *
                         *  client_c.Connect(Server, Port, SecureSocketOptions.SslOnConnect);
                         *
                         *  client_c.AuthenticationMechanisms.Remove("XOAUTH2");
                         *
                         *  client_c.Authenticate(Email, Password);
                         *
                         *  client_c.Send(email);
                         *
                         *  client_c.Disconnect(true);
                         * }*/
                        //here


                        bidReqRepo.Update(bidreq);
                        //TODO: redirect to a modal! partial view..?
                        return(RedirectToAction("Success"));
                    }
                    else
                    {
                        foreach (IdentityError error in result.Errors)
                        {
                            ModelState.AddModelError("", error.Description);
                        }
                        return(View(bidreq));
                    }
                }
            }
            //if the email already exists return to view
            ViewBag.Error = "The email already exists in the database.";
            return(View(bidreq));
        }
 /// <summary>
 /// <para>Performs the Bidding Method:
 /// Place a bid request. POST
 /// </para><para>
 /// Serializes the given BidRequest into xml and sends the message.
 /// </para>
 /// REQUIRES AUTHENTICATION.
 /// </summary>
 /// <param name="request">The object that will be serialized into xml and then sent in a POST message.</param>
 /// <returns>XDocument: AuctionBidResponse</returns>
 public XDocument BidRequest(BidRequest request)
 {
     var query = String.Format(Constants.Culture, "{0}/Bid{1}", Constants.BIDDING, Constants.XML);
     return _connection.Post(request, query);
 }