Exemplo n.º 1
0
        /// <summary>
        /// Returns information about the parameters found on the given type
        /// </summary>
        /// <param name="type">The type to find Parameter attributes for</param>
        /// <returns>A list of ParameterDef objects which describe the InputCommandNamed arameters
        /// found on in the type</returns>
        private static List <ParameterDef> GetParameterDefinitions(Type type)
        {
            List <ParameterDef> infoList = new List <ParameterDef>();

            PropertyInfo[] propertiesList = type.GetProperties();
            foreach (var property in propertiesList)
            {
                Parameter parameterAttribute = GetAttributes <Parameter>(property).FirstOrDefault();
                Synopsis  synopsisAttribute  = GetAttributes <Synopsis>(property).FirstOrDefault();

                if (parameterAttribute != null)
                {
                    ParameterDef info = new ParameterDef();
                    info.PropertyInfo = property;
                    info.Name         = parameterAttribute.ParameterName ?? property.Name;
                    info.AddAliases(GetAttributes <Alias>(property).Select(a => a.Value));
                    info.IsRequired                   = parameterAttribute.IsRequired;
                    info.OrdinalPosition              = parameterAttribute.OrdinalPosition;
                    info.Synopsis                     = synopsisAttribute == null ? null : synopsisAttribute.Value;
                    info.ParameterSet                 = parameterAttribute.ParameterSet;
                    info.AutoCompleteValuesFunction   = parameterAttribute.AutoCompleteValuesFunction;
                    info.UseAutoCompleteForValidation = parameterAttribute.UseAutoCompleteForValidation;
                    info.ValidationFunction           = parameterAttribute.ValidationFunction;

                    infoList.Add(info);
                }
            }

            return(infoList);
        }
Exemplo n.º 2
0
 public ActionResult Edit(Synopsis synopsis, HttpPostedFileBase fileUpload)
 {
     if (Session["userName"] != null)
     {
         if (fileUpload != null)
         {
             using (var ms = new MemoryStream())
             {
                 fileUpload.InputStream.CopyTo(ms);
                 synopsis.File = ms.ToArray();
             }
             if (ModelState.IsValid)
             {
                 db.Entry(synopsis).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
         return(View(synopsis));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
Exemplo n.º 3
0
        private static List <SwitchDef> GetSwitchDefinitions(Type type)
        {
            List <SwitchDef> switches = new List <SwitchDef>();

            PropertyInfo[] propertiesList = type.GetProperties();

            foreach (var property in propertiesList)
            {
                Switch   switchAttribute   = GetAttributes <Switch>(property).FirstOrDefault();
                Synopsis synopsisAttribute = GetAttributes <Synopsis>(property).FirstOrDefault();

                if (switchAttribute != null)
                {
                    SwitchDef newSwitch = new SwitchDef();
                    newSwitch.PropertyInfo = property;
                    newSwitch.Name         = switchAttribute.Name ?? property.Name;
                    newSwitch.AddAliases(GetAttributes <Alias>(property).Select(a => a.Value));
                    newSwitch.Synopsis = synopsisAttribute == null ? null : synopsisAttribute.Value;

                    switches.Add(newSwitch);
                }
            }

            return(switches);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns an <typeparamref name="BitPantry.Console.API.InputCommandInfo" object/>
        /// </summary>
        /// <param name="inputCommandType">The type to define</param>
        /// <returns>Returns an <typeparamref name="BitPantry.Console.API.InputCommandInfo" object. Or NULL if the type is not an Input Command</returns>
        public static InputCommandDef DescribeInputCommand(this Type inputCommandType)
        {
            // check base type

            if (!inputCommandType.IsSubclassOf(typeof(InputCommand)))
            {
                throw new ArgumentException(string.Format("The input command {0} does not extend {1}"
                                                          , inputCommandType.FullName, typeof(InputCommand).FullName));
            }

            // check for command attribute

            Command commandAttr = GetAttributes <Command>(inputCommandType).FirstOrDefault();

            if (commandAttr == null)
            {
                throw new ArgumentException(string.Format("The input command {0} does not have the {1} attribute"
                                                          , inputCommandType.FullName, typeof(Command).FullName));
            }

            // return if already cached

            if (!definitionCache.Keys.Any(k => k.Equals(inputCommandType)))
            {
                // initialize info for new

                InputCommandDef info = new InputCommandDef();
                info.InputCommandType    = inputCommandType;
                info.CommandName         = commandAttr.Name ?? inputCommandType.Name;
                info.DefaultParameterSet = commandAttr.DefaultParameterSet;

                // parse aliases

                info.AddAliases(GetAttributes <Alias>(inputCommandType).Select(a => a.Value));

                // parse parameter definitions

                info.Add(GetParameterDefinitions(inputCommandType));

                // parse switches

                info.Add(GetSwitchDefinitions(inputCommandType));

                // parse synopsis

                Synopsis synopsisAttribute = GetAttributes <Synopsis>(inputCommandType).FirstOrDefault();
                info.Synopsis = synopsisAttribute == null ? null : synopsisAttribute.Value;

                CommandValidator.Validate(info);

                // cache new definition

                definitionCache.Add(inputCommandType, info);
            }

            return(definitionCache[inputCommandType]);
        }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Synopsis != null ? Synopsis.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CriticsConsensus != null ? CriticsConsensus.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Year;
         return(hashCode);
     }
 }
Exemplo n.º 6
0
 public override void PrepareProperties()
 {
     base.PrepareProperties();
     if (!string.IsNullOrEmpty(RawSynopsisData.Trim()))
     {
         Synopsis.Clear();
         Synopsis.AddRange(RawSynopsisData.Trim().Split(new char[] { ';', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList());
         Synopsis.ForEach(s => s = s.Trim());
     }
 }
Exemplo n.º 7
0
        public Synopsis CreateSynopsis(string movieTitle, string text)
        {
            Synopsis synopsis = new Synopsis
            {
                MovieTitle = movieTitle,
                Text       = text
            };

            return(synopsis);
        }
 private void LoadPreviousValues(object sender, RoutedEventArgs e)
 {
     if (Summary == null)
     {
         Summary = new Synopsis();
     }
     else
     {
         TXTBX_Synopsis.Text = Summary.Summary;
     }
 }
Exemplo n.º 9
0
        public override int GetHashCode()
        {
            int ret = (Title != null) ? Title.GetHashCode() : 0;

            ret  = (ret * 397) ^ ((EpisodeNumber != null) ? EpisodeNumber.GetHashCode() : 0);
            ret  = (ret * 397) ^ ((EpisodeTitle != null) ? EpisodeTitle.GetHashCode() : 0);
            ret  = (ret * 397) ^ ((Synopsis != null) ? Synopsis.GetHashCode() : 0);
            ret  = (ret * 397) ^ ((Team1 != null) ? Team1.GetHashCode() : 0);
            ret  = (ret * 397) ^ ((Team2 != null) ? Team2.GetHashCode() : 0);
            ret  = (ret * 397) ^ SeriesID.GetHashCode();
            ret &= 0x7fffffff;

            return(ret);
        }
        void ReleaseDesignerOutlets()
        {
            if (Cast != null)
            {
                Cast.Dispose();
                Cast = null;
            }

            if (Mpaa != null)
            {
                Mpaa.Dispose();
                Mpaa = null;
            }

            if (RunningTime != null)
            {
                RunningTime.Dispose();
                RunningTime = null;
            }

            if (ReleaseDate != null)
            {
                ReleaseDate.Dispose();
                ReleaseDate = null;
            }

            if (Synopsis != null)
            {
                Synopsis.Dispose();
                Synopsis = null;
            }

            if (RottenIndicator != null)
            {
                RottenIndicator.Dispose();
                RottenIndicator = null;
            }

            if (CriticReview != null)
            {
                CriticReview.Dispose();
                CriticReview = null;
            }

            if (Director != null)
            {
                Director.Dispose();
                Director = null;
            }
        }
Exemplo n.º 11
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["userName"] != null)
     {
         Synopsis synopsis = db.Synopsis.Find(id);
         db.Synopsis.Remove(synopsis);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
Exemplo n.º 12
0
        public ActionResult CreateSynopsis(Synopsis synopsis, HttpPostedFileBase fileUpload)
        {
            using (var ms = new MemoryStream())
            {
                fileUpload.InputStream.CopyTo(ms);
                synopsis.File = ms.ToArray();
            }
            if (ModelState.IsValid)
            {
                db.Synopsis.Add(synopsis);
                db.SaveChanges();
                return(RedirectToAction("Synopses"));
            }

            return(View(synopsis));
        }
Exemplo n.º 13
0
        public IActionResult Synopsis([FromBody] Synopsis model)
        {
            var userId        = _http.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "00000000-0000-0000-0000-000000000000";
            var authenticated = _http.HttpContext.User.Identity.IsAuthenticated;

            if (model == null)
            {
                return(BadRequest());
            }

            if (model.UserId != userId || !authenticated)
            {
                return(BadRequest());
            }

            var user = _db.Users.Find(userId);

            if (user == null)
            {
                return(BadRequest());
            }

            var amenities = _db.UsersAmenities.Where(x => x.UserId == user.Id).ToList();

            foreach (var am in amenities)
            {
                _db.UsersAmenities.Remove(am);
                _db.SaveChanges();
            }

            foreach (var am in model.Services)
            {
                if (am.Checked)
                {
                    var amenitie = _db.Amenities.Find(am.AmenitieId);
                    _db.UsersAmenities.Add(new UsersAmenities {
                        Id = Guid.NewGuid().ToString(), IsChecked = am.Checked, AmenitieId = amenitie.Id, UserId = user.Id
                    });
                    _db.SaveChanges();
                }
            }

            return(Ok());
        }
Exemplo n.º 14
0
        public Synopsis Synopsis(string id)
        {
            var userId        = _http.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "00000000-0000-0000-0000-000000000000";
            var authenticated = _http.HttpContext.User.Identity.IsAuthenticated;


            if (id != userId || !authenticated)
            {
                return(null);
            }

            var user = _db.Users.Find(userId);

            if (user == null)
            {
                return(null);
            }

            var appAmenities       = _db.Amenities.ToList();
            List <BizService> list = new List <BizService>();

            foreach (var am in appAmenities)
            {
                if (!_db.UsersAmenities.Any(x => x.AmenitieId == am.Id && x.UserId == user.Id))
                {
                    list.Add(new BizService {
                        Name = am.FrenchName, Checked = false, AmenitieId = am.Id
                    });
                }
                else
                {
                    list.Add(new BizService {
                        Name = am.FrenchName, Checked = true, AmenitieId = am.Id
                    });
                }
            }

            Synopsis model = new Synopsis {
                UserId = user.Id, Services = list
            };

            return(model);
        }
Exemplo n.º 15
0
 // GET: Synopses/Details/5
 public ActionResult Details(int?id)
 {
     if (Session["userName"] != null)
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Synopsis synopsis = db.Synopsis.Find(id);
         if (synopsis == null)
         {
             return(HttpNotFound());
         }
         return(View(synopsis));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
Exemplo n.º 16
0
        public Synopsis getSynopsis(string fromDate, string toDate)
        {
            Synopsis result = new Synopsis();

            result.advanceDirectives       = getAdvanceDirectives(fromDate, toDate, 50);
            result.allergies               = getAllergies();
            result.chemHemReports          = getChemHemReports(fromDate, toDate, 50);
            result.detailedHealthSummaries = getDetailedHealthSummary();
            result.healthSummaries         = getHealthSummary();
            result.immunizations           = getImmunizations(fromDate, toDate, 50);
            result.medications             = getOutpatientMeds();
            result.microbiologyReports     = getMicrobiologyReports(fromDate, toDate, 50);
            result.supplements             = getOtherMeds();
            result.problemLists            = getProblemList("ACTIVE");
            result.radiologyReports        = getRadiologyReports(fromDate, toDate, 50);
            result.surgeryReports          = getSurgeryReports();
            result.vitalSigns              = getVitalSigns();
            SitesLib sitesLib = new SitesLib(MySession);

            result.treatingFacilities = sitesLib.getConnectedSites();
            return(result);
        }
Exemplo n.º 17
0
 public SynopsisViewer(Synopsis synopsis)
 {
     InitializeComponent();
     DisplayedSynopsis = synopsis;
 }