Пример #1
0
        private Building CreateBuildingObject(BuildingEditingModel obj)
        {
            Building entityObject = new Building();

            entityObject.Id             = obj.Id;
            entityObject.Address        = obj.Address;
            entityObject.BuildingType   = btRepository.GetByName(obj.BuildingTypeName);
            entityObject.BuildingTypeId = entityObject.BuildingType.Id;
            entityObject.FloorsNumber   = obj.FloorsNumber;
            entityObject.Area           = obj.Area;
            entityObject.Note           = obj.Note;
            entityObject.Description    = obj.Description;
            entityObject.UserId         = User.Identity.GetUserId();
            //entityObject.UserId = obj.UserId;

            if (obj.Photos == null)
            {
                entityObject.Photos = SaveFiles(obj.Files);
            }
            else
            {
                entityObject.Photos = obj.Files != null?obj.Photos.Union(SaveFiles(obj.Files)).ToArray() : obj.Photos;
            }

            return(entityObject);
        }
        private BuildingType CreateBuildingTypeObject(BuildingTypeEditingModel obj)
        {
            BuildingType entityObject = new BuildingType();

            entityObject.Id          = obj.Id;
            entityObject.Name        = obj.Name;
            entityObject.Parent      = repository.GetByName(obj.ParentName);
            entityObject.ParentId    = entityObject.Parent?.Id;
            entityObject.Description = obj.Description;
            entityObject.UserId      = User.Identity.GetUserId();
            //entityObject.UserId = obj.UserId;
            return(entityObject);
        }