Exemplo n.º 1
0
        public Base AddItem(AddItemRequest request)
        {
            Base viewModel = new Base();

            try
            {
                // Prendo l'originId del tipo di item
                OR_ItemType itemType = getItemType(request.ItemType);

                // Creo l'item
                string  itemOriginId = Guid.NewGuid().ToString();
                OR_Item item         = new OR_Item()
                {
                    OriginId         = itemOriginId,
                    ItemTypeOriginId = itemType.OriginId,
                    LastEditDate     = DateTime.Now,
                    CreationDate     = DateTime.Now
                };
                _dataContext.OR_Items.InsertOnSubmit(item);
                _dataContext.SubmitChanges();

                // Per ogni input creo la relativa property
                foreach (AddItemRequest.Input input in request.Inputs)
                {
                    string      propertyOriginId = Guid.NewGuid().ToString();
                    OR_Property property         = new OR_Property()
                    {
                        OriginId        = propertyOriginId,
                        RelatedOriginId = item.OriginId,
                        Name            = input.Name,
                        Value           = input.Value
                    };
                    _dataContext.OR_Properties.InsertOnSubmit(property);
                }

                // NB. Gli input vengono aggiornati automaticamente al submit
                _dataContext.SubmitChanges();
            }
            catch (Exception exc)
            {
                viewModel.ResultInfo.Result       = Base.ResultInfoDto.ResultEnum.Error;
                viewModel.ResultInfo.ErrorMessage = exc.Message;
            }

            return(viewModel);
        }
Exemplo n.º 2
0
 partial void UpdateOR_Property(OR_Property instance);
Exemplo n.º 3
0
 partial void DeleteOR_Property(OR_Property instance);
Exemplo n.º 4
0
 partial void InsertOR_Property(OR_Property instance);