Exemplo n.º 1
0
        public async Task <IHttpActionResult> SendEmailUpdateMenu([FromBody] MenuUpdateMessageDto messageDto)
        {
            if (messageDto == null)
            {
                return(BadRequest());
            }
            MessageService.SendUpdateDayMenuMessage(_unitOfWork.RepositoryAsync <WeekOrderMenu>(), messageDto);

            return(Ok(true));
        }
Exemplo n.º 2
0
        public static void SendUpdateDayMenuMessage(IRepositoryAsync <WeekOrderMenu> repo, MenuUpdateMessageDto mesdto)
        {
            int[] dayids = mesdto.UpdatedDayMenu.Select(upd => upd.DayMenuId).Distinct().ToArray();

            foreach (int id in dayids)
            {
                StringBuilder strbild      = new StringBuilder();
                List <User>   bookingUsers = repo.GetUsersMadeOrder(id);
                strbild.AppendLine("<table class='table-responsive table-striped'>");
                //strbild.AppendLine("<thead><tr><th><th><th>Старое блюдо</th><th>Новое блюдо</th></tr></thead>");
                strbild.AppendLine("<tbody>");

                foreach (var mdch in mesdto.UpdatedDayMenu.Where(dm => dm.DayMenuId == id).ToList())
                {
                    Dish olddish = repo.GetRepositoryAsync <Dish>().Find(mdch.OldDishId);
                    Dish newdish = repo.GetRepositoryAsync <Dish>().Find(mdch.NewDishId);
                    strbild.AppendLine("<tr>");
                    strbild.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td>", mdch.Category, olddish.Title,
                                         newdish.Title);
                    strbild.AppendLine("</tr>");
                }
                strbild.AppendLine("</tbody>");
                strbild.AppendLine("</table>");
                List <User> userBooking = repo.GetUsersMadeOrder(id);
                SendEmailAsync(userBooking, MessageTopic.MenuChanged, mesdto.DateTime,
                               strbild.ToString());
            }
        }