public ActionResult AddContainer(int id, string remain, string container, string bay)
        {
            var viewschedule = _context.ScheduleDetails.Include(b => b.ShipDetails).SingleOrDefault(b => b.Id == id);

            BookScheduleViewModel bsvm = new BookScheduleViewModel
            {
                ScheduleDetails = viewschedule
            };

            int baysize = 0;

            if (string.IsNullOrWhiteSpace(bay) || string.IsNullOrWhiteSpace(container))
            {
                return(Json(new { success = false, message = "Please fill in all the fields completely." }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                baysize = Convert.ToInt32(bay);
            }

            var             total = 0;
            var             ori   = Convert.ToInt32(remain);
            ContainerModels c     = new ContainerModels
            {
                ContainerType   = container,
                NumberOfBayUsed = baysize
            };

            total = total + baysize;

            if (bm.ContainerModels.Count > 0) // if there are exisiting container type with number of bay in the list
            {
                foreach (var i in bm.ContainerModels)
                {
                    total += i.NumberOfBayUsed;
                }
            }

            if (ori >= total)
            {
                bm.ContainerModels.Add(c);
            }
            else
            {
                //ViewBag.IsSuccess = false;
                //ViewBag.Message = "The bay size of the ship selected is lesser than the amount you wanted.";
                //return View("Booking", bsvm);
                return(Json(new { success = false, message = "The bay size of the ship selected is lesser than the amount you wanted." }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 读取模型关键字评论的Xml文件
        /// </summary>
        /// <returns></returns>
        public static ContainerModels ReadKeyComments()
        {
            ContainerModels result = new ContainerModels();
            DataSet         dt     = new DataSet();

            dt.ReadXml("KeyComment.xml".GetFileResource("Xml"));
            if (dt != null && dt.Tables.Count > 0)
            {
                foreach (DataRow item in dt.Tables[0].Rows)
                {
                    result.Add(item["name"].ToString(), item["value"].ToString(), item["comment"].ToString(), DateTime.Parse(item["time"].ToString()), 1);
                }
            }
            return(result);
        }