Exemple #1
0
 public LawnSection(Models.LawnSection lawnSection)
 {
     Id          = lawnSection.Id;
     Name        = lawnSection.Name;
     Description = lawnSection.Description;
     ImageUrl    = lawnSection.ImageUrl;
     SquareFeet  = lawnSection.SquareFeet;
 }
        public async Task <Models.LawnSection> Create(string lawnId, LawnSectionForCreate newLawnSection)
        {
            var lawn = await GetLawnAsync(lawnId);

            var lawnSection = new Models.LawnSection
            {
                Id          = ObjectId.GenerateNewId().ToString(),
                Name        = newLawnSection.Name,
                Description = newLawnSection.Description,
                ImageUrl    = newLawnSection.ImageUrl,
                SquareFeet  = newLawnSection.SquareFeet,
                CreatedDate = DateTime.UtcNow,
                UpdatedDate = DateTime.UtcNow
            };

            lawn.Sections.Add(lawnSection);
            await _lawns.ReplaceOneAsync(l => l.Id == lawnId, lawn);

            return(lawnSection);
        }