public ActionResult Create(string name, string imges)
        {
            if (name != "" && imges != "")
            {
                string[] im = imges.Split(',');
                List<int> images = new List<int>();
                foreach (var i in im)
                {
                    images.Add(Convert.ToInt32(i));
                }

                Routine r = new Routine();
                r.Name = name;
                r.AdminID = MVCExtensions.getCurrentAdmin().ID;
                r.Createddate = DateTime.UtcNow;

                Adapter.RoutineRepository.Insert(r);
                Adapter.Save();

                var it = 1;
                foreach (var img in images)
                {
                    RoutineImage ri = new RoutineImage();
                    ri.ImageId= img;
                    ri.RoutineId = r.ID;
                    ri.ImageOrder = it;
                    Adapter.RoutineImageRepository.Insert(ri);
                    Adapter.Save();
                    r.ImagesInRoutine.Add(ri);
                    it++;
                }
                Adapter.Save();

                return Content("200");
            }
            return Content("401");
        }
        public ActionResult Edit(string name, string imgs, string id)
        {
            if (name != "" && imgs != "" && id != "")
            {
                string[] im = imgs.Split(',');
                List<int> images = new List<int>();
                foreach (var i in im)
                {
                    images.Add(Convert.ToInt32(i));
                }

                Routine r = Adapter.RoutineRepository.GetByID(Convert.ToInt32(id));
                r.Name = name;
                r.Modifieddate = DateTime.UtcNow;
                Adapter.RoutineRepository.Update(r);
                Adapter.Save();
                List<RoutineImage> delete = r.ImagesInRoutine.ToList();

                foreach (var rim in delete)
                {
                    Adapter.RoutineImageRepository.Delete(rim);
                }

                Adapter.Save();

                var it = 1;
                foreach (var img in images)
                {
                    RoutineImage ri = new RoutineImage();
                    ri.ImageId = img;
                    ri.RoutineId = r.ID;
                    ri.ImageOrder = it;
                    Adapter.RoutineImageRepository.Insert(ri);
                    Adapter.Save();
                    r.ImagesInRoutine.Add(ri);
                    it++;
                }
                Adapter.Save();

                return Content("200");
            }
            return Content("401");
        }