Exemple #1
0
        public IHttpActionResult Put([FromBody] data.Attribute attr)
        {
            var principal = (User)User.Identity;

            attr.ModifiedBy   = principal.Id;
            attr.ModifiedDate = DateTime.Now;
            Repository.Update(attr);
            Repository.Save();
            var message = "The Attribute \"" + attr.ShortName + "\" has been Updated";

            Log.MonitoringLogger.Info(message);
            return(Ok(message));
        }
Exemple #2
0
        public IHttpActionResult Post([FromBody] data.Attribute attr)
        {
            attr.IsActive = true;
            var principal = (User)User.Identity;

            if (Repository.FindBy <data.Attribute>(u => u.ShortName == attr.ShortName).Any())
            {
                var warningMessage = "The Attribute \"" + attr.ShortName + "\" already exists";
                // Log.MonitoringLogger.Warn(warningMessage);
                ModelState.AddModelError("alreadyexits", warningMessage);
                return(BadRequest(ModelState));
            }

            attr.CreatedBy   = principal.Username;
            attr.CreatedDate = DateTime.Now;
            Repository.Add(attr);
            Repository.Save();
            var message = "The Attribute \"" + attr.ShortName + "\" has been added";

            Log.MonitoringLogger.Info(message);
            return(Ok(message));
        }