public OperationDetails CreateOther(ProductDTO product, OtherDTO item, string oldOther)
        {
            Product productInDB = Database.Products.Find(p => p.Name == oldOther).FirstOrDefault();

            if (productInDB != null)
            {
                return(UpdateOther(product, item, oldOther));
            }

            if (item == null || product == null)
            {
                return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString()));
            }
            Other other = _mappers.ToOther.Map <OtherDTO, Other>(item);

            item.Name = product.Name;
            Database.Others.Add(other);
            Database.Save();

            Product localProduct = _mappers.ToProduct.Map <ProductDTO, Product>(product);

            if (localProduct == null)
            {
                return(new OperationDetails(false, "Не удалось преобразовать объект", this.ToString()));
            }
            localProduct       = CreateProduct(localProduct);
            localProduct.Table = Goods.Other;
            Other otherInDB = Database.Others.Find(x => x.Name == localProduct.Name).FirstOrDefault();

            if (otherInDB == null)
            {
                return(new OperationDetails(false, "Не удалось найти объект", this.ToString()));
            }
            localProduct.FromTableId = otherInDB.Id;
            Database.Products.Add(localProduct);
            Database.Save();
            return(new OperationDetails(true, "Товар был успешно добавлен", this.ToString()));
        }
        public OperationDetails UpdateOther(ProductDTO product, OtherDTO item, string oldOtherName)
        {
            if (product == null || item == null)
            {
                return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString()));
            }
            Product localProduct = UpdateProduct(product);

            Database.Products.Update(localProduct);

            Other oldOther = Database.Others.Find(x => x.Name == oldOtherName).FirstOrDefault();

            if (oldOther == null)
            {
                return(new OperationDetails(false, "Не удалось найти объект", this.ToString()));
            }
            oldOther.Name       = item.Name;
            oldOther.Type       = item.Type;
            oldOther.Properties = _mappers.ToProperty.Map <IEnumerable <PropertyDTO>, ICollection <Property> >(item.Properties);
            Database.Others.Update(oldOther);
            Database.Save();
            return(new OperationDetails(true, "Товар успешно изменён", this.ToString()));
        }