Esempio n. 1
0
 public void Create(LinkUserToList link)
 {
     using (var context = new ListItContext())
     {
         var linkresult = context.LinkUserToLists.Add(link);
         try
         {
             context.SaveChanges();
         }
         catch (System.Data.Entity.Validation.DbEntityValidationException e)
         {
             StringBuilder builder = new StringBuilder();
             foreach (var eve in e.EntityValidationErrors)
             {
                 builder.Append("Entity of type " + eve.Entry.Entity.GetType().Name
                                + " in state " + eve.Entry.State + " has the following" +
                                " validation errors:");
                 foreach (var ve in eve.ValidationErrors)
                 {
                     builder.Append("Property: " + ve.PropertyName + ", Error: " + ve.ErrorMessage);
                 }
             }
             throw new Exception(builder.ToString());
         }
     }
 }
        public void CreateLink(ShoppingListDto dto)
        {
            var link = new LinkUserToList
            {
                UserId           = dto.UserId,
                ShoppingListId   = dto.Id,
                ListAccessTypeId = dto.ListAccessTypeId,
            };

            _listRepository.Create(link);
        }
 public static ShoppingListDto StaticLinkDBToDto(LinkUserToList link, ShoppingList list)
 {
     return(new ShoppingListDto
     {
         Id = list.Id,
         Name = list.Name,
         Path = list.Path,
         TimeStamp = list.Timestamp,
         ChosenSortingId = list.ChosenSorting_Id,
         ListAccessTypeId = link.ListAccessTypeId
     });
 }
        public override void Create(ShoppingListDto dto)
        {
            var list = new ShoppingList
            {
                Id               = dto.Id,
                Name             = dto.Name,
                Path             = dto.Path,
                Timestamp        = DateTime.Now,
                ChosenSorting_Id = dto.ChosenSortingId
            };

            var link = new LinkUserToList
            {
                UserId           = dto.UserId,
                ShoppingListId   = dto.Id,
                ListAccessTypeId = dto.ListAccessTypeId,
            };

            _listRepository.Create(list, link);
        }
 protected ShoppingListDto ConvertDBToDtoWithListAccessType(LinkUserToList link, ShoppingList list)
 {
     return(StaticLinkDBToDto(link, list));
 }