Inheritance: System.Data.Objects.DataClasses.EntityObject
コード例 #1
0
 /// <summary>
 /// Create a new File object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="fileName">Initial value of the FileName property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static File CreateFile(global::System.Int32 id, global::System.String fileName, global::System.String description)
 {
     File file = new File();
     file.Id = id;
     file.FileName = fileName;
     file.Description = description;
     return file;
 }
コード例 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the FileSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFileSet(File file)
 {
     base.AddObject("FileSet", file);
 }
コード例 #3
0
ファイル: FileHelpers.cs プロジェクト: janmarek/Felbook
 public string GetHtml(File file)
 {
     return "<a href=\"" + service.GetFileHref(file) + "\" target=\"_blank\">" + file.FileName + "</a>";
 }
コード例 #4
0
ファイル: StatusService.cs プロジェクト: janmarek/Felbook
        public void AddStatus(User user, Group group, Event ev, StatusFormModel formModel)
        {
            if (group != null)
            {
                if (!group.HasMember(user))
                {
                    throw new StatusException("User is not member of group");
                }
            }

            var status = new Status { Text = formModel.Status, User = user, Group = group, Event = ev };
            db.AddToStatusSet(status);

            // obrázky
            if (formModel.Images != null)
            {
                for (int i = 0; i < formModel.Images.Count; i++)
                {
                    var uploadedImage = formModel.Images[i];

                    // vynechat neobrázky
                    if (uploadedImage == null || uploadedImage.ContentLength == 0 || !ImageHelper.IsImage(uploadedImage.ContentType))
                    {
                        continue;
                    }

                    // vyrobit entitu
                    var img = new Image {
                        Description = formModel.ImageDescriptions[i],
                    };
                    db.ImageSet.AddObject(img);

                    status.Images.Add(img);

                    // uložit db, aby entita měla id a tudíž se dala vymyslet cesta k obrázku
                    db.SaveChanges();

                    // uložit soubor
                    imageService.SaveImage(img, uploadedImage.InputStream);
                }
            }

            // soubory
            if (formModel.Files != null)
            {
                for (int i = 0; i < formModel.Files.Count; i++)
                {
                    var uploadedFile = formModel.Files[i];

                    if (uploadedFile == null || uploadedFile.ContentLength == 0)
                    {
                        continue;
                    }

                    // vyrobit entitu
                    var file = new File {
                        Description = formModel.FileDescriptions[i],
                        FileName = uploadedFile.FileName,
                    };
                    db.FileSet.AddObject(file);

                    status.Files.Add(file);

                    // uložit db, aby entita měla id a tudíž se dala vymyslet cesta k souboru
                    db.SaveChanges();

                    // uložit soubor
                    fileService.SaveFile(file, uploadedFile);
                }
            }

            // odkazy
            if (formModel.Links != null)
            {
                for (int i = 0; i < formModel.Links.Count; i++)
                {
                    var url = formModel.Links[i];

                    if (String.IsNullOrWhiteSpace(url))
                    {
                        continue;
                    }

                    status.Links.Add(new Link {
                        URL = url,
                        Description = formModel.LinkDescriptions[i],
                    });
                }
            }

            db.SaveChanges();

            // přidat do zdí
            List<User> userList = user.Followers.ToList();

            if (group != null)
            {
                userList.Union(group.Users);
            }
            else
            {
                userList.Add(user);
            }

            wallService.Add(status, userList.Distinct());
        }
コード例 #5
0
ファイル: MockFileService.cs プロジェクト: janmarek/Felbook
 public void SaveFile(File file, System.Web.HttpPostedFileBase uploadedFile)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
ファイル: MockFileService.cs プロジェクト: janmarek/Felbook
 public string GetFilePath(File file)
 {
     throw new NotImplementedException();
 }