Inheritance: System.Data.Objects.DataClasses.EntityObject
コード例 #1
0
ファイル: EventService.cs プロジェクト: janmarek/Felbook
        public void AddEvent(User user, Group group, DateTime from, DateTime to, String name, String text)
        {
            Event ev = new Event();
            ev.Group = group;
            ev.User = user;
            ev.From = from;
            ev.To = to;
            ev.Name = name;
            ev.Text = text;

            db.AddToEventSet(ev);

            db.SaveChanges();
        }
コード例 #2
0
ファイル: MockStatusService.cs プロジェクト: janmarek/Felbook
 public void AddStatus(User user, Event ev, StatusFormModel formModel)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
 /// <summary>
 /// Create a new Event object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="from">Initial value of the From property.</param>
 /// <param name="to">Initial value of the To property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 public static Event CreateEvent(global::System.Int32 id, global::System.DateTime from, global::System.DateTime to, global::System.String name, global::System.String text)
 {
     Event @event = new Event();
     @event.Id = id;
     @event.From = from;
     @event.To = to;
     @event.Name = name;
     @event.Text = text;
     return @event;
 }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the EventSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEventSet(Event @event)
 {
     base.AddObject("EventSet", @event);
 }
コード例 #5
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());
        }
コード例 #6
0
ファイル: StatusService.cs プロジェクト: janmarek/Felbook
 public void AddStatus(User user, Event ev, StatusFormModel formModel)
 {
     AddStatus(user, null, ev, formModel);
 }