示例#1
0
 public static OrderedTour_ExcursionSight AddNewExcursionSightToOrederedTour(OrderedTour_ExcursionSight objExcursionSightToOrderedTour)
 {
     using (UserContext db = new UserContext())
     {
         db.OrderedTour_ExcursionSights.Add(objExcursionSightToOrderedTour);
         db.SaveChanges();
     }
     return(objExcursionSightToOrderedTour);
 }
示例#2
0
 public static Boolean EditExcursionIdinOrderedTour(OrderedTour_ExcursionSight ExcursionSightToOrderedTour, int?ExcursionSightId)
 {
     using (UserContext db = new UserContext())
     {
         ExcursionSightToOrderedTour.ExcursionSightId = ExcursionSightId;
         db.Entry(ExcursionSightToOrderedTour).State  = EntityState.Modified;
         db.SaveChanges();
     }
     return(true);
 }
        public static OrderedTour_ExcursionSight AddExcursionSight(int orderedTourId, int?ExcursionSightId, int OrdinalNumber)
        {
            OrderedTour_ExcursionSight objExcursionSightToOrderedTour = new OrderedTour_ExcursionSight
            {
                OrderedTourId    = orderedTourId,
                ExcursionSightId = ExcursionSightId,
                OrdinalNumber    = OrdinalNumber
            };

            return(OrderedTourManager.AddNewExcursionSightToOrederedTour(objExcursionSightToOrderedTour));
        }
        public ActionResult Edit(TourModel Model)
        {
            string error = "";

            try
            {
                if (ModelState.IsValid)
                {
                    int ClientId    = GetClientId(Model.ClientName);
                    int ExcursionId = GetExcursionId(Model.ExcursionName);

                    OrderedTourManager.EditTourInfo(Model.OrderedTourId, Model.Date, ClientId, ExcursionId);
                    List <OrderedTour_ExcursionSight> excursionSight = excMan.GetExcursionSightInfo(Model.OrderedTourId);

                    var Count = excursionSight.Count > Model.ExcursionSight.Count ? excursionSight.Count : Model.ExcursionSight.Count;

                    int?excursionSightId;
                    for (int i = 0; i < Count; i++)
                    {
                        try
                        {
                            excursionSightId = (int)GetExcursionSightId(Model.ExcursionSight[i], ExcursionId);
                        }
                        catch
                        {
                            excursionSightId = null;
                        }


                        OrderedTour_ExcursionSight ExcursionSightToOrderedTour = OrderedTourManager.GetExcursionSightId(i, Model.OrderedTourId);
                        if (ExcursionSightToOrderedTour != null)
                        {
                            OrderedTourManager.EditExcursionIdinOrderedTour(ExcursionSightToOrderedTour, excursionSightId);
                        }
                        else
                        {
                            AddExcursionSight(Model.OrderedTourId, excursionSightId, i);
                        }
                    }
                }
                else
                {
                    error = "Form is incorrect.";
                    return(Json(new { status = false, error }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { status = true, error }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                error = "Error occured:" + ex.Message;
                return(Json(new { status = false, error }, JsonRequestBehavior.AllowGet));
            }
        }