Inheritance: Record
Esempio n. 1
0
        public bool activityCreate(Activity _act)
        {
            string prefix = "activity0-";
            //Go to activites page
            WaitThenClickElement(By.Id("menulinkactivity"));
            //Go to create an activity tab
            WaitThenClickElement(By.Id("activityCreateTab"));
            //Wait for page to load
            WaitForElement(By.Id(prefix + "type"));
            //Enter information
            SelectOptionByValue(By.Id(prefix + "type"), _act.type.ToString());
            WaitForElement(By.Id(prefix + "name"));
            SelectOptionByValue(By.Id(prefix + "name"), _act.name.ToString());
            SelectOption(By.Id(prefix + "teacher"), _act.teacher);
            ReplaceElementText(By.Id(prefix + "notes"), _act.notes);
            //Hit the save button
            _d.FindElement(By.Id(prefix + "SaveBtn")).Click();
            //Look for new tab with class: activity.ui-tabs-selected
            var selectedTab = WaitForElement(By.CssSelector("li.activity.ui-tabs-selected"));
            Assert.IsNotNull(selectedTab, "Failed to find Activity selected tab element");
            IWebElement tabAnchor = selectedTab.FindElement(By.CssSelector("a"));
            Assert.IsNotNull(tabAnchor, "Failed to find Activity selected tab element anchor");
            _act.ID = Convert.ToInt32(tabAnchor.GetAttribute("recordid"));

            return true;
        }
Esempio n. 2
0
        public ActionResult CreateMany(int id)
        {
            Activity firstAct = serv.Get(id);
            var      m        = map.Map <Activity, ActivitySchedule>(firstAct);

            m.def = def;
            return(PartialView("CreateMany", m));
        }
        public ActionResult CreateMany(int id)
        {
            Activity firstAct = _serv.Get(id);

            MapperHelpers.ClientTimeZoneInfo = _clientTimeZoneInfo;
            MapperHelpers.Defaults           = _defaults;
            var m = _map.Map <Activity, ActivitySchedule>(firstAct);

            return(PartialView("CreateMany", m));
        }
Esempio n. 4
0
        public JsonResult Edit(int id, FormCollection collection, string userName)
        {
            Activity activity = serv.Get(id);

            UpdateModel(activity);
            serv.Save(activity, userName);
            return(Json(new
            {
                jobSuccess = true
            }));
        }
Esempio n. 5
0
 public ActivitySchedule(Activity firstAct)
 {
     idString = "activity";
     this.firstID = firstAct.ID;
     this.name = firstAct.name;
     this.type = firstAct.type;
     this.dateStart = firstAct.dateStart;
     this.dateEnd = firstAct.dateEnd;
     this.teacher = firstAct.teacher;
     this.notes = firstAct.notes;
 }
        public async Task <JsonResult> Create(Activity activity, string userName)
        {
            if (!await TryUpdateModelAsync(activity, ""))
            {
                return(Json(new { jobSuccess = false }));
            }
            if (activity.dateEnd < activity.dateStart)
            {
                return(Json(new { jobSuccess = false, rtnMessage = "End date must be greater than start date." }));
            }

            // leave for now, can be substituted with a reference method
            var assemblyType      = _defaults.byKeys(LCategory.activityType, LActType.Assembly);
            var assemblyName      = _defaults.byKeys(LCategory.activityName, LActName.Assembly);
            var orgMtgType        = _defaults.byKeys(LCategory.activityType, LActType.OrgMtg);
            var orgMtgName        = _defaults.byKeys(LCategory.activityName, LActName.OrgMtg);
            var activityNameEmpty = activity.nameID == 0;

            activity.notes = activity.notes ?? "";

            if (activity.typeID == assemblyType && activityNameEmpty)
            {
                activity.nameID = assemblyName;
            }
            if (activity.typeID == orgMtgType && activityNameEmpty)
            {
                activity.nameID = orgMtgName;
            }
            activity.firstID = activity.ID;
            //

            activity.dateStart = TimeZoneInfo.ConvertTimeToUtc(activity.dateStart, _clientTimeZoneInfo);
            activity.dateEnd   = TimeZoneInfo.ConvertTimeToUtc(activity.dateEnd, _clientTimeZoneInfo);
            activity           = _serv.Create(activity, userName);

            var result = _map.Map <Activity, ViewModel.Activity>(activity);

            // there are no dates to worry about in this mapping

            return(Json(new
            {
                sNewRef = result.tabref,
                sNewLabel = result.tablabel,
                iNewID = result.ID,
                jobSuccess = true
            }));
        }
        public ActionResult Create()
        {
            var now       = DateTime.Now;
            var utcNow    = TimeZoneInfo.ConvertTimeToUtc(now, _serverTimeZoneInfo);
            var clientNow = TimeZoneInfo.ConvertTimeFromUtc(utcNow, _clientTimeZoneInfo);

            var activity = new Activity
            {
                dateStart = clientNow,
                dateEnd   = clientNow.AddHours(1)
            };
            var m = _map.Map <Activity, ViewModel.Activity>(activity);

            m.def = _defaults;

            return(PartialView("Create", m));
        }
Esempio n. 8
0
        public void Integration_Activity_service_CreateClass_within_hour()
        {
            IEnumerable<int> cardlist = frb.ToRepoWorker().GetAllQ().Select(q => q.dwccardnum).Distinct();
            IEnumerable<int> classlist = frb.ToRepoLookup().GetAllQ().Where(l => l.category == "activityName").Select(q => q.ID);
            Activity a = new Activity();
            //random date, within last 30 days
            Random rand = new Random();
            DateTime today = DateTime.Now;
            a.dateStart = today;
            a.dateEnd = a.dateStart.AddHours(1.5);
            a.name = classlist.ElementAt(rand.Next(classlist.Count()));
            a.type = 101; //type==class
            a.teacher = "UnitTest script";
            a.notes = "From Integration_Activity_Service";
            frb.ToServActivity().Create(a, "TestScript");

            Assert.IsTrue(1 == frb.ToRepoActivity().GetAllQ().Where(aa => aa.ID == a.ID).Count());
        }
Esempio n. 9
0
        public JsonResult Create(Activity activ, string userName)
        {
            UpdateModel(activ);
            activ.firstID = activ.ID;

            if (activ.nameID == 0)
            {
                if (activ.typeID == def.byKeys(LCategory.activityType, LActType.Assembly))
                {
                    activ.nameID = def.byKeys(LCategory.activityName, LActName.Assembly);
                }
                else if (activ.typeID == def.byKeys(LCategory.activityType, LActType.OrgMtg))
                {
                    activ.nameID = def.byKeys(LCategory.activityName, LActName.OrgMtg);
                }
                else
                {
                    throw new MacheteIntegrityException("Something went wrong with Activity Types.");
                }
            }

            if (activ.dateEnd < activ.dateStart)
            {
                return(Json(new { jobSuccess = false, rtnMessage = "End date must be greater than start date." }));
            }

            Activity firstAct = serv.Create(activ, userName);
            var      result   = map.Map <Activity, ViewModel.Activity>(firstAct);

            if (activ.recurring)
            {
                result.tablabel = "Recurring event with " + firstAct.teacher;
                result.tabref   = "/Activity/CreateMany/" + Convert.ToString(firstAct.ID);
            }


            return(Json(new
            {
                sNewRef = result.tabref,
                sNewLabel = result.tablabel,
                iNewID = result.ID,
                jobSuccess = true
            }));
        }
Esempio n. 10
0
        public JsonResult DeleteMany(int id, string userName)
        {
            Activity   firstToDelete = serv.Get(id);
            List <int> allToDelete   = serv.GetAll()
                                       .Where(w => w.firstID == firstToDelete.firstID && w.dateStart >= firstToDelete.dateStart)
                                       .Select(s => s.ID).ToList();

            foreach (int toDelete in allToDelete)
            {
                serv.Delete(toDelete, userName);
            }

            return(Json(new
            {
                status = "OK",
                jobSuccess = true,
                deletedID = id
            }));
        }
Esempio n. 11
0
        public bool activityValidate(Activity _act)
        {
            string prefix = "activity" + _act.ID + "-";
            //Wait for the page to load
            WaitForElement(By.Id(prefix + "name"));

            Assert.AreEqual(1, GetOptionIndex(By.Id(prefix + "name")));
            Assert.AreEqual(1, GetOptionIndex(By.Id(prefix + "type")));
            Assert.AreEqual(_act.teacher, GetOptionText(By.Id(prefix + "teacher")));
            Assert.AreEqual(_act.notes, WaitForElement(By.Id(prefix + "notes")).GetAttribute("value"));
            return true;
        }
Esempio n. 12
0
 public ActionResult Create()
 {
     var _model = new Activity();
     _model.dateStart = DateTime.Now;
     _model.dateEnd = DateTime.Now.AddHours(1);
     return PartialView("Create", _model);
 }
Esempio n. 13
0
        public JsonResult CreateMany(ActivitySchedule actSched, string userName)
        {
            UpdateModel(actSched); // copy values from form to object. why this is necessary if the object is being passed as arg, I don't know.
            var firstActivity = serv.Get(actSched.firstID);
            var instances     = actSched.stopDate.Subtract(actSched.dateStart).Days;
            var length        = actSched.dateEnd.Subtract(actSched.dateStart).TotalMinutes;

            for (var i = 0; i <= instances; ++i) // This should skip right over firstAct.
            {
                var date = actSched.dateStart.AddDays(i);
                var day  = (int)date.DayOfWeek;

                if (day == 0 && !actSched.sunday)
                {
                    continue;
                }
                if (day == 1 && !actSched.monday)
                {
                    continue;
                }
                if (day == 2 && !actSched.tuesday)
                {
                    continue;
                }
                if (day == 3 && !actSched.wednesday)
                {
                    continue;
                }
                if (day == 4 && !actSched.thursday)
                {
                    continue;
                }
                if (day == 5 && !actSched.friday)
                {
                    continue;
                }
                if (day == 6 && !actSched.saturday)
                {
                    continue;
                }
                var activ = new Activity();
                activ.nameID    = actSched.name;
                activ.typeID    = actSched.type;
                activ.dateStart = date;
                activ.dateEnd   = date.AddMinutes(length);
                activ.recurring = true;
                activ.firstID   = firstActivity.ID;
                activ.teacher   = actSched.teacher;
                activ.notes     = actSched.notes;

                var act = serv.Create(activ, userName);
            }
            var result = map.Map <Activity, ViewModel.Activity>(firstActivity);

            return(Json(new
            {
                sNewRef = result.tabref,
                sNewLabel = result.tablabel,
                iNewID = firstActivity.ID,
                jobSuccess = true
            }));
        }
Esempio n. 14
0
        public JsonResult Create(Activity activ, string userName)
        {
            UpdateModel(activ);
            activ.firstID = activ.ID;

            if (activ.name == 0)
            {
                if (activ.type == lcache.getByKeys(LCategory.activityType, LActType.Assembly))
                    activ.name = lcache.getByKeys(LCategory.activityName, LActName.Assembly);
                else if (activ.type == lcache.getByKeys(LCategory.activityType, LActType.OrgMtg))
                    activ.name = lcache.getByKeys(LCategory.activityName, LActName.OrgMtg);
                else
                    throw new MacheteIntegrityException("Something went wrong with Activity Types.");
            }

            if (activ.dateEnd < activ.dateStart)
                return Json(new { jobSuccess = false, rtnMessage = "End date must be greater than start date." });
            else if (activ.recurring == true)
            {
                Activity firstAct = serv.Create(activ, userName);

                return Json(new
                {
                    sNewRef = CreateManyTabRef(firstAct),
                    sNewLabel = CreateManyTabLabel(firstAct),
                    iNewID = activ.ID,
                    jobSuccess = true
                });
            }
            else {
                Activity newActivity = serv.Create(activ, userName);

                return Json(new
                {
                    sNewRef = EditTabRef(newActivity),
                    sNewLabel = EditTabLabel(newActivity),
                    iNewID = newActivity.ID,
                    jobSuccess = true
                },
                JsonRequestBehavior.AllowGet);
            }
        }
Esempio n. 15
0
 public void Integration_Activity_Service_CreateRandomClass()
 {
     //Used once to create dummy data to support report creation
     // requires change in app.config to point test database to production
     IEnumerable<int> cardlist = frb.ToRepoWorker().GetAllQ().Select(q => q.dwccardnum).Distinct();
     IEnumerable<int> classlist = frb.ToRepoLookup().GetAllQ().Where(l => l.category == "activityName").Select(q => q.ID);
     Activity a = new Activity();
     //random date, within last 30 days
     Random rand = new Random();
     DateTime today = DateTime.Today.AddDays(-rand.Next(40));
     a.dateStart = today.AddHours(7 + rand.Next(5));
     a.dateEnd = a.dateStart.AddHours(1.5);
     a.name = classlist.ElementAt(rand.Next(classlist.Count()));
     a.type = 101; //type==class
     a.teacher = "UnitTest script";
     a.notes = "From Integration_Activity_Service";
     frb.ToServActivity().Create(a, "TestScript");
     int rAttendance = rand.Next(cardlist.Count() / 10);
     for (var i = 0; i < rAttendance; i++)
     {
         ActivitySignin asi = (ActivitySignin)Records.activitysignin.Clone();
         asi.dateforsignin = today;
         asi.activityID = a.ID;
         asi.dwccardnum = cardlist.ElementAt(rand.Next(cardlist.Count()));
         frb.ToServActivitySignin().CreateSignin(asi, "TestScript");
     }
     //a.
 }
Esempio n. 16
0
        public async Task <ViewResult> CreateMany(ActivitySchedule actSched, string userName)
        {
            var instances = actSched.stopDate.Subtract(actSched.dateStart).Days;

            if (!await TryUpdateModelAsync(actSched) || instances == 0)
            {
                ModelState.AddModelError("ActivitySchedule", "Select an appropriate length of time for these events.");
                return(View("CreateMany", actSched)); //Json(new { jobSuccess = false });
            }

            var length  = actSched.dateEnd.Subtract(actSched.dateStart).TotalMinutes;
            var utcDate = TimeZoneInfo.ConvertTimeToUtc(actSched.dateStart, _clientTimeZoneInfo);

            for (var i = 1; i <= instances; i++)
            {
                var currentDate = utcDate.AddDays(i);
                var day         = (int)currentDate.DayOfWeek;

                if (day == 0 && !actSched.sunday)
                {
                    continue;
                }
                if (day == 1 && !actSched.monday)
                {
                    continue;
                }
                if (day == 2 && !actSched.tuesday)
                {
                    continue;
                }
                if (day == 3 && !actSched.wednesday)
                {
                    continue;
                }
                if (day == 4 && !actSched.thursday)
                {
                    continue;
                }
                if (day == 5 && !actSched.friday)
                {
                    continue;
                }
                if (day == 6 && !actSched.saturday)
                {
                    continue;
                }

                var activity = new Activity
                {
                    nameID    = actSched.name,
                    typeID    = actSched.type,
                    dateStart = currentDate,
                    dateEnd   = currentDate.AddMinutes(length),
                    recurring = true,
                    firstID   = actSched.firstID,
                    teacher   = actSched.teacher,
                    notes     = actSched.notes ?? ""
                };

                _serv.Create(activity, userName);
            }

            // Machete: A series of good intentions, marinated in panic ~C
//            var result = _map.Map<Activity, ViewModel.Activity>(firstActivity);
//            return Json(new
//            {
//                sNewRef = result.tabref,
//                sNewLabel = result.tablabel,
//                iNewID = firstActivity.ID,
//                jobSuccess = true
//            });
            return(View("Index"));
        }
Esempio n. 17
0
        public JsonResult CreateMany(ActivitySchedule actSched, string userName)
        {
            UpdateModel(actSched); // copy values from form to object. why this is necessary if the object is being passed as arg, I don't know.
            Activity firstActivity = serv.Get(actSched.firstID);
            var instances = actSched.stopDate.Subtract(actSched.dateStart).Days;
            var length = actSched.dateEnd.Subtract(actSched.dateStart).TotalMinutes;

            for (var i = 0; i <= instances; ++i) // This should skip right over firstAct.
            {
                var date = actSched.dateStart.AddDays(i);
                var day = (int)date.DayOfWeek;

                if (day == 0 && !actSched.sunday) ;
                else if (day == 1 && !actSched.monday) ;
                else if (day == 2 && !actSched.tuesday) ;
                else if (day == 3 && !actSched.wednesday) ;
                else if (day == 4 && !actSched.thursday) ;
                else if (day == 5 && !actSched.friday) ;
                else if (day == 6 && !actSched.saturday) ;
                else
                {
                    var activ = new Activity();
                    activ.name = actSched.name;
                    activ.type = actSched.type;
                    activ.dateStart = date;
                    activ.dateEnd = date.AddMinutes(length);
                    activ.recurring = true;
                    activ.firstID = firstActivity.ID;
                    activ.teacher = actSched.teacher;
                    activ.notes = actSched.notes;

                    Activity act = serv.Create(activ, userName);
                }
            }

            return Json(new
            {
                sNewRef = EditTabRef(firstActivity),
                sNewLabel = EditTabLabel(firstActivity),
                iNewID = firstActivity.ID,
                jobSuccess = true
            },
            JsonRequestBehavior.AllowGet);
        }
Esempio n. 18
0
 private string CreateManyTabLabel(Activity act)
 {
     if (act == null) return null;
     return "Recurring Event with " + act.teacher;
 }
Esempio n. 19
0
 private string EditTabRef(Activity act)
 {
     if (act == null) return null;
     return "/Activity/Edit/" + Convert.ToString(act.ID);
 }
Esempio n. 20
0
 private string EditTabLabel(Activity act)
 {
     if (act == null) return null;
     return lcache.textByID(act.name, CI.TwoLetterISOLanguageName) + " with " +
             act.teacher;
 }
Esempio n. 21
0
 private object dtResponse(ref Activity p)
 {
     return new
     {
         tabref = EditTabRef(p),
         tablabel = EditTabLabel(p),
         name = lcache.textByID(p.name, CI.TwoLetterISOLanguageName),
         type = lcache.textByID(p.type, CI.TwoLetterISOLanguageName),
         count = p.Signins.Count(),
         teacher = p.teacher,
         dateStart = p.dateStart.ToString(),
         dateEnd = p.dateEnd.ToString(),
         AID = Convert.ToString(p.ID),
         recordid = Convert.ToString(p.ID),
         dateupdated = Convert.ToString(p.dateupdated),
         Updatedby = p.Updatedby
     };
 }
Esempio n. 22
0
 private string CreateManyTabRef(Activity act)
 {
     if (act == null) return null;
     return "/Activity/CreateMany/" + Convert.ToString(act.ID);
 }