public DbResponse <AttributeModel> Add(AttributeAddModel model, string userName) { try { var registrationId = _db.Registration.GetRegID_ByUserName(userName); if (registrationId == 0) { return(new DbResponse <AttributeModel>(false, "Invalid User")); } model.CreatedByRegistrationId = registrationId; if (string.IsNullOrEmpty(model.KeyName)) { return(new DbResponse <AttributeModel>(false, "Invalid Data")); } if (_db.Attribute.IsExistName(model.KeyName)) { return(new DbResponse <AttributeModel>(false, "Attribute Name already Exist", null, "Name")); } _db.Attribute.Add(model); _db.SaveChanges(); var data = _mapper.Map <AttributeModel>(_db.Attribute.Attribute); return(new DbResponse <AttributeModel>(true, "Success", data)); } catch (Exception e) { return(new DbResponse <AttributeModel>(false, e.Message)); } }
public IActionResult Add(AttributeAddModel model) { var response = _attribute.Add(model, User.Identity.Name); return(Json(response)); }