public JsonResult ToGrid(TableSettings settings) {
   int ClientId;
   IEnumerable<DishWish> DishWishList = null;
   int recordsTotal;
   int recordsFiltered;
   int draw;
   try {
     ClientId = Int32.Parse(Session["ClientId"].ToString());
     using(ProjetWEBEntities contect = new ProjetWEBEntities()) {
       DishWishList = contect.DishWish.Where(dishWish => dishWish.ClientId == ClientId).ToArray();
       recordsTotal = DishWishList.Count();
     }
     if(settings != null) {
       DishWishList = Filter(DishWishList, settings.Search);
       DishWishList = Order(DishWishList, settings.SortColumn, settings.SortOrder);
       recordsFiltered = DishWishList.Count();
       if(settings.Length > 0) {
         DishWishList = DishWishList.Skip(settings.Start).Take(settings.Length).ToArray();
       }
       draw = settings.Draw;
     } else {
       recordsFiltered = DishWishList.Count();
       draw = 1;
     }
     var data = ConvertDishWishTable(DishWishList);
     return Json(new { data = data, draw = draw, recordsTotal = recordsTotal, recordsFiltered = recordsFiltered }, JsonRequestBehavior.AllowGet);
   } catch(Exception ex) {
     ExceptionUtility.LogException(ex, Request.RawUrl);
     return Json(new { draw = settings.Draw, error = "Une erreur est survenue lors de la récupération des données" });
   }
 }
 public ActionResult Index() {
   IList<Reception> model = new List<Reception>();
   using(ProjetWEBEntities context = new ProjetWEBEntities()) {
     model = context.Reception.ToList();
   }
   return View(model);
 }
 private IEnumerable <DishWishModel> GetDishWishes()
 {
     try {
         using (ProjetWEBEntities context = new ProjetWEBEntities()) {
             var result = from dw in context.DishWish
                          select new DishWishModel {
                 ClientFirstName = dw.ClientFirstName,
                 ClientId        = dw.ClientId,
                 ClientLastName  = dw.ClientLastName,
                 DishId          = dw.DishId,
                 DishName        = dw.DishName,
                 DishType        = dw.DishType,
                 DishTypeId      = dw.DishTypeId,
                 Feeling         = dw.Feeling,
                 FeelingTypeId   = dw.FeelingTypeId,
                 ModifiedAt      = dw.ModifiedAt,
                 ModifiedBy      = dw.ModifiedBy
             };
             return((result == null) ? null : result.ToArray());
         }
     } catch (Exception ex) {
         ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
         return(null);
     }
 }
        public ActionResult Index()
        {
            IList <Reception> model = new List <Reception>();

            using (ProjetWEBEntities context = new ProjetWEBEntities()) {
                model = context.Reception.ToList();
            }
            return(View(model));
        }
예제 #5
0
 private IEnumerable<Dish> GetDishes() {
   try {
     using(ProjetWEBEntities context = new ProjetWEBEntities()) {
       return context.Dish.ToArray();
     }
   } catch(Exception ex) {
     ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
     return null;
   }
 }
 public ActionResult Create(NewReceptionModel model)
 {
     if (ModelState.IsValid)
     {
         try {
             using (ProjetWEBEntities context = new ProjetWEBEntities()) {
                 var             Acronym    = Session["Acronym"].ToString();
                 string          imgname    = "";
                 string          imgdirpath = Server.MapPath("~/Content/images/");
                 ObjectParameter RecId      = new ObjectParameter("RecId", typeof(int));
                 if (model.Poster.ContentLength > 0)
                 {
                     imgname = model.Poster.FileName;
                     int i = 1;
                     while (System.IO.File.Exists(imgdirpath + imgname))
                     {
                         imgname = i.ToString() + '_' + model.Poster.FileName;
                         i++;
                     }
                     model.Poster.SaveAs(imgdirpath + imgname);
                 }
                 context.NewReception(model.Name,
                                      model.Date,
                                      model.BookingClosingDate,
                                      model.Capacity,
                                      model.SeatsPerTable,
                                      ((model.Poster.ContentLength > 0) ? imgname : null),
                                      Acronym,
                                      RecId);
                 foreach (int DishId in model.StartersId)
                 {
                     context.NewMenu((int)RecId.Value, DishId, Acronym);
                 }
                 foreach (int DishId in model.MainCoursesId)
                 {
                     context.NewMenu((int)RecId.Value, DishId, Acronym);
                 }
                 foreach (int DishId in model.DessertsId)
                 {
                     context.NewMenu((int)RecId.Value, DishId, Acronym);
                 }
             }
             return(RedirectToAction("Index", "Reception"));
         } catch (Exception ex) {
             ExceptionUtility.LogException(ex, Request.RawUrl);
             return(RedirectToAction("Index", "Error"));
         }
     }
     else
     {
         SetViewBagCreate();
         return(View(model));
     }
 }
예제 #7
0
 public object Create([FromBody]DishWishModel model) {
   try {
     using(ProjetWEBEntities context = new ProjetWEBEntities()) {
       context.NewWishedDish(model.ClientId, model.DishId, model.FeelingTypeId, model.ModifiedBy);
     }
     return new { Message = "OK" };
   } catch(Exception ex) {
     ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
     return new { Message = "FAIL" };
   }
 }
예제 #8
0
 private IEnumerable <DishStatistic> GetDishesStatistic()
 {
     try {
         using (ProjetWEBEntities context = new ProjetWEBEntities()) {
             return(context.DishStatistic.ToArray());
         }
     } catch (Exception ex) {
         ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
         return(null);
     }
 }
 public object Delete([FromBody] DishWishModel model)
 {
     try {
         using (ProjetWEBEntities context = new ProjetWEBEntities()) {
             context.DeleteDishWish(model.ClientId, model.DishId, model.ModifiedAt);
         }
         return(new { Message = "OK" });
     } catch (Exception ex) {
         ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
         return(new { Message = "FAIL" });
     }
 }
        public ActionResult Login(LoginFormModel model, string returnUrl)
        {
            C_CLIENT logged;

            if (ModelState.IsValid)
            {
                using (ProjetWEBEntities context = new ProjetWEBEntities()) {
                    try {
                        logged = context.C_CLIENT.Where(client => client.CLI_EMAIL.Equals(model.UserName) && client.CLI_PASSWORD.Equals(model.Password)).First();
                    } catch {
                        logged = null;
                    }
                }
                if (logged != null)
                {
                    Session.Clear();
                    Session["FirstName"] = logged.CLI_FNAME;
                    Session["LastName"]  = logged.CLI_LNAME;
                    Session["Acronym"]   = logged.CLI_ACRONYM;
                    Session["ClientId"]  = logged.CLI_ID;
                    var ticket           = LoginHelper.CreateAuthenticationTicket(logged.CLI_ACRONYM, logged.CLI_GROUP, false);
                    var encrypetedTicket = FormsAuthentication.Encrypt(ticket);
                    FormsAuthentication.SetAuthCookie(encrypetedTicket, false);
                    if (String.IsNullOrEmpty(returnUrl))
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        returnUrl = Server.UrlDecode(returnUrl);
                        if (Url.IsLocalUrl(returnUrl))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Nom d'utilisateur ou mot de passe incorrect");
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
예제 #11
0
 public ActionResult Login(LoginFormModel model, string returnUrl = "")
 {
    User logged;
     if (ModelState.IsValid)
     {
         using (ProjetWEBEntities context = new ProjetWEBEntities())
         {
             try
             {
                 logged = context.User.Where(guest => guest.Email.Equals(model.Email) && guest.Password.Equals(model.Password)).First();
             }
             catch
             {
                 logged = null;
             }
         }
         if (logged != null)
         {
             Session.Clear();
            var ticket = LoginHelper.CreateAuthenticationTicket(logged.Email, logged.Group, false);
             var encrypetedTicket = FormsAuthentication.Encrypt(ticket);
             FormsAuthentication.SetAuthCookie(encrypetedTicket, false);
             if (String.IsNullOrEmpty(returnUrl))
             {
                 return RedirectToAction("Index", "Home");
             }
             else
             {
                 returnUrl = Server.UrlDecode(returnUrl);
                 if (Url.IsLocalUrl(returnUrl))
                 {
                     return Redirect(returnUrl);
                 }
                 else
                 {
                     return RedirectToAction("Index", "Home");
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "Username or Password is incorrect");
             return View(model);
         }
     }
     else
     {
         return View(model);
     }
 }
 public ActionResult Create(NewReceptionModel model) {
   if(ModelState.IsValid) {
     try {
       using(ProjetWEBEntities context = new ProjetWEBEntities()) {
         var Acronym = Session["Acronym"].ToString();
         string imgname = "";
         string imgdirpath = Server.MapPath("~/Content/images/");
         ObjectParameter RecId = new ObjectParameter("RecId", typeof(int));
         if(model.Poster.ContentLength > 0) {
           imgname = model.Poster.FileName;
           int i = 1;
           while(System.IO.File.Exists(imgdirpath + imgname)) {
             imgname = i.ToString() + '_' + model.Poster.FileName;
             i++;
           }
           model.Poster.SaveAs(imgdirpath + imgname);
         }
         context.NewReception(model.Name,
                              model.Date,
                              model.BookingClosingDate,
                              model.Capacity,
                              model.SeatsPerTable,
                              ((model.Poster.ContentLength > 0) ? imgname : null),
                              Acronym,
                              RecId);
         foreach(int DishId in model.StartersId) {
           context.NewMenu((int)RecId.Value, DishId, Acronym);
         }
         foreach(int DishId in model.MainCoursesId) {
           context.NewMenu((int)RecId.Value, DishId, Acronym);
         }
         foreach(int DishId in model.DessertsId) {
           context.NewMenu((int)RecId.Value, DishId, Acronym);
         }
       }
       return RedirectToAction("Index", "Reception");
     } catch(Exception ex) {
       ExceptionUtility.LogException(ex, Request.RawUrl);
       return RedirectToAction("Index", "Error");
     }
   } else {
     SetViewBagCreate();
     return View(model);
   }
 }
 private IEnumerable <DishWishModel> GetUnwished(int ClientId)
 {
     try {
         using (ProjetWEBEntities context = new ProjetWEBEntities()) {
             var result = from dw in context.GetUnwishedDish(ClientId)
                          select new DishWishModel {
                 DishId     = dw.DishId,
                 DishName   = dw.Name,
                 DishType   = dw.Type,
                 DishTypeId = dw.DishTypeId
             };
             return((result == null) ? null : result.ToArray());
         }
     } catch (Exception ex) {
         ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
         return(null);
     }
 }
예제 #14
0
 public ActionResult Login(LoginFormModel model, string returnUrl) {
   C_CLIENT logged;
   if(ModelState.IsValid) {
     using(ProjetWEBEntities context = new ProjetWEBEntities()) {
       try {
         logged = context.C_CLIENT.Where(client => client.CLI_EMAIL.Equals(model.UserName) && client.CLI_PASSWORD.Equals(model.Password)).First();
       } catch {
         logged = null;
       }
     }
     if(logged != null) {
       Session.Clear();
       Session["FirstName"] = logged.CLI_FNAME;
       Session["LastName"] = logged.CLI_LNAME;
       Session["Acronym"] = logged.CLI_ACRONYM;
       Session["ClientId"] = logged.CLI_ID;
       var ticket = LoginHelper.CreateAuthenticationTicket(logged.CLI_ACRONYM, logged.CLI_GROUP, false);
       var encrypetedTicket = FormsAuthentication.Encrypt(ticket);
       FormsAuthentication.SetAuthCookie(encrypetedTicket, false);
       if(String.IsNullOrEmpty(returnUrl)) {
         return RedirectToAction("Index", "Home");
       } else {
         returnUrl = Server.UrlDecode(returnUrl);
         if(Url.IsLocalUrl(returnUrl)) {
           return Redirect(returnUrl);
         } else {
           return RedirectToAction("Index", "Home");
         }
       }
     } else {
       ModelState.AddModelError("", "Nom d'utilisateur ou mot de passe incorrect");
       return View(model);
     }
   } else {
     return View(model);
   }
 }
예제 #15
0
        public JsonResult ToGrid(TableSettings settings)
        {
            int ClientId;
            IEnumerable <DishWish> DishWishList = null;
            int recordsTotal;
            int recordsFiltered;
            int draw;

            try {
                ClientId = Int32.Parse(Session["ClientId"].ToString());
                using (ProjetWEBEntities contect = new ProjetWEBEntities()) {
                    DishWishList = contect.DishWish.Where(dishWish => dishWish.ClientId == ClientId).ToArray();
                    recordsTotal = DishWishList.Count();
                }
                if (settings != null)
                {
                    DishWishList    = Filter(DishWishList, settings.Search);
                    DishWishList    = Order(DishWishList, settings.SortColumn, settings.SortOrder);
                    recordsFiltered = DishWishList.Count();
                    if (settings.Length > 0)
                    {
                        DishWishList = DishWishList.Skip(settings.Start).Take(settings.Length).ToArray();
                    }
                    draw = settings.Draw;
                }
                else
                {
                    recordsFiltered = DishWishList.Count();
                    draw            = 1;
                }
                var data = ConvertDishWishTable(DishWishList);
                return(Json(new { data = data, draw = draw, recordsTotal = recordsTotal, recordsFiltered = recordsFiltered }, JsonRequestBehavior.AllowGet));
            } catch (Exception ex) {
                ExceptionUtility.LogException(ex, Request.RawUrl);
                return(Json(new { draw = settings.Draw, error = "Une erreur est survenue lors de la récupération des données" }));
            }
        }
예제 #16
0
 private IEnumerable<DishWishModel> GetDishWishes() {
   try {
     using(ProjetWEBEntities context = new ProjetWEBEntities()) {
       var result = from dw in context.DishWish
                    select new DishWishModel {
                      ClientFirstName = dw.ClientFirstName,
                      ClientId = dw.ClientId,
                      ClientLastName = dw.ClientLastName,
                      DishId = dw.DishId,
                      DishName = dw.DishName,
                      DishType = dw.DishType,
                      DishTypeId = dw.DishTypeId,
                      Feeling = dw.Feeling,
                      FeelingTypeId = dw.FeelingTypeId,
                      ModifiedAt = dw.ModifiedAt,
                      ModifiedBy = dw.ModifiedBy
                    };
       return (result == null) ? null : result.ToArray();
     }
   } catch(Exception ex) {
     ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
     return null;
   }
 }
예제 #17
0
 private IEnumerable<DishWishModel> GetUnwished(int ClientId) {
   try {
     using(ProjetWEBEntities context = new ProjetWEBEntities()) {
       var result = from dw in context.GetUnwishedDish(ClientId)
                    select new DishWishModel {
                      DishId = dw.DishId,
                      DishName = dw.Name,
                      DishType = dw.Type,
                      DishTypeId = dw.DishTypeId
                    };
       return (result == null) ? null : result.ToArray();
     }
   } catch(Exception ex) {
     ExceptionUtility.LogException(ex, HttpContext.Current.Request.RawUrl);
     return null;
   }
 }