public IHttpActionResult Get(int id)
        {
            var category = offerRepository.Get(id);

            if (category == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            return(Ok(offerRepository.Get(id)));
        }
예제 #2
0
파일: SOffer.cs 프로젝트: Yac-Mc/ZonaFLGit
        public Offer Get(int id)
        {
            OfferRepository <Offer>             Offerrepo  = new OfferRepository <Offer>();
            OfferPhasesRepository <OfferPhases> OfferPrepo = new OfferPhasesRepository <OfferPhases>();
            var offer = Offerrepo.Get(id);

            offer.OfferPhases = new List <OfferPhases>();
            offer.OfferPhases = OfferPrepo.GetPhasesByIdOffer(id).ToList();
            return(offer);
        }
예제 #3
0
        private static bool SendMailToRequestor(Order order)
        {
            Offer       offer = OfferRepository.Get(order.OfferId);
            MailMessage mail  = new MailMessage(AppAddress, new MailAddress(order.RequestorEmail));

            mail.Subject = "Your order was submitted!";

            StringBuilder body = new StringBuilder();

            body.Append(string.Format("Hi {0}!\r\n", order.RequestorName));
            body.Append("\r\n");
            body.Append("You order was submitted.\r\n");
            body.Append(string.Format("You can contact {0} by {1}. \r\n", offer.OwnerName, offer.OwnerEmail));
            body.Append(string.Format("You declared to meet him {0}.\r\n", order.ReceiveTime));
            body.Append("Please be on time to pick up:\r\n");
            foreach (var p in offer.Products)
            {
                if (order.ProductIds.Contains(p.ProductId))
                {
                    body.Append(string.Format("* {0},\r\n", p.Name));
                }
            }
            body.Append("\r\n");
            body.Append("Have a great day!\r\n FoodSharingNetwork");

            mail.Body = body.ToString();

            try
            {
                smtpClient.Send(mail);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #4
0
        private static bool SendMailToCreator(Order order)
        {
            Offer       offer = OfferRepository.Get(order.OfferId);
            MailMessage mail  = new MailMessage(AppAddress, new MailAddress(offer.OwnerEmail));

            mail.Subject = "Your offer was accepted!";

            StringBuilder body = new StringBuilder();

            body.Append(string.Format("Hi {0}!\r\n", offer.OwnerName));
            body.Append("\r\n");
            body.Append(string.Format("Your offer \"{0}\" was accepted by {1}.\r\n", offer.OfferDescription, order.RequestorName));
            body.Append(string.Format("You can contact him by {0}. \r\n", order.RequestorEmail));
            body.Append(string.Format("He will meet with you {0}.\r\n", order.ReceiveTime));
            body.Append("Please prepare following products for him to pick up:\r\n");
            foreach (var p in offer.Products)
            {
                if (order.ProductIds.Contains(p.ProductId))
                {
                    body.Append(string.Format("* {0},\r\n", p.Name));
                }
            }
            body.Append("\r\n");
            body.Append("Have a great day!\r\n FoodSharingNetwork");

            mail.Body = body.ToString();

            try
            {
                smtpClient.Send(mail);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #5
0
 public IActionResult Get(Guid id)
 {
     return(Ok(OfferRepository.Get(id)));
 }