Esempio n. 1
0
        private LicenseModel BuildModel(ILicense license)
        {
            var licenseModel = new LicenseModel
            {
                Id          = license.Id,
                Description = license.Description,
            };

            TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
            int      secondsSinceEpoch = (int)t.TotalSeconds;

            licenseModel.TimeStamp = secondsSinceEpoch;

            return(licenseModel);
        }
Esempio n. 2
0
        public IActionResult Post(LicenseModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            ILicense license = this.LicenseManager.Default();

            license.Description = model.Description;

            this.LicenseManager.Create(license);

            var created = this.BuildModel(license);

            // nope
            return(this.CreatedAtAction("Get", created));
        }