Beispiel #1
0
        public void CanCreateAlarmTypeAndLog()
        {
            IRepository<AlarmType> repoA = new AlarmTypeRepository();
            AlarmType alarm = new AlarmType();
            alarm.NameAlarmType = "PruebaAlarma";
            alarm.Description = "Prueba descriptiva alarma";

            repoA.Save(alarm);

            IRepository<User> repoB = new UserRepository();
            User user = new User();
            user = repoB.GetById(1);
            IRepository<Event> repoC = new EventRepository();
            Event eventt = new Event();
            eventt = repoC.GetById(2);

            IRepository<Log> repoD = new LogRepository();
            Log log = new Log();
            log.DateTime = DateTime.Now;
            log.Text = "Prueba descriptiva log";
            log.Event = eventt;
            log.User = user;

            repoD.Save(log);
        }
Beispiel #2
0
        public ActionResult Create(Event eventt, FormCollection form)
        {
            ViewData["ValidationErrorMessage"] = String.Empty;
            if (this.FormCollectionIsValid(form))
            {
                db.Save(this.RemoveExtraSpaces(eventt));

                List<Object> logList = new List<Object>();
                logList.Add(log.GetNewLog(ConfigurationManager.AppSettings["CreateText"] + ControllerContext.RouteData.Values["controller"] + "(Id=" + eventt.Id.ToString().Replace("-", "").ToUpper() + " - Description=" + eventt.Description + " - Name=" + eventt.Name + ")", (int)EventTypes.Create, (int)Session["UserId"]));
                log.Write(logList);

                return RedirectToAction("Index");
            }

            return View(eventt);
        }
Beispiel #3
0
        private Event RemoveExtraSpaces(Event eventt)
        {
            eventt.Name = !String.IsNullOrWhiteSpace(eventt.Name) ? eventt.Name.Trim() : null;
            eventt.Description = !String.IsNullOrWhiteSpace(eventt.Description) ? eventt.Description.Trim() : null;

            return eventt;
        }