Exemplo n.º 1
0
        public bool AcceptOffer(Offer offer)
        {
            try
            {
                if (paymentDal.FindByProjectId(offer.ProjectId) == null)
                {
                    Project project = projectDal.GetProject(offer.ProjectId);
                    project.WorkerId = offer.UserId;
                    projectDal.UpdateProject(project);
                    freelanceContext.SaveChanges();

                    Payment payment = new Payment();
                    payment.ProjectId     = offer.ProjectId;
                    payment.AcceptedPrice = offer.OfferPrice;

                    paymentDal.AddToPool(payment);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }