public async Task <IActionResult> Post([FromBody] UserData userData)
        {
            if (userData == null)
            {
                return(BadRequest());
            }

            var addedData = await _dataService.Add(userData);

            return(CreatedAtRoute("GetData", new { id = addedData.UserId }, addedData));
        }
        public override async Task Handle(RegisterAccountRequestModel command)
        {
            UserEntity user = mapper.Map <RegisterAccountRequestModel, UserEntity>(command);

            await userDataService.Add(user);
        }
Exemple #3
0
        public IActionResult Add([FromBody] dynamic value)
        {
            try
            {
                string svalue = Convert.ToString(value);

                dynamic UserJsonEntity = JsonConvert.DeserializeObject(svalue);

                string firstname    = UserJsonEntity["fn"];
                string lastname     = UserJsonEntity["ln"];
                string licencekey   = UserJsonEntity["lk"];
                var    seatkey      = UserJsonEntity["sk"];
                string optionaldata = UserJsonEntity["opt"];
                var    devicetype   = UserJsonEntity["dt"];
                var    devicemodel  = UserJsonEntity["dm"];


                //get the enterprise encryption key
                Subscription subscription = _subscriptionService.GetByLicenceKey(licencekey);
                if (subscription == null)
                {
                    return(Json(new
                    {
                        c = ResultCode.UserDataResultCodes.SubscriptionDoesntExist,
                        d = ""
                    }));
                }

                EKey eKey = _eKeyService.GetActive(subscription.EnterpriseClientId);

                if (eKey != null)
                {
                    _userDataService.Add(new Entity.Model.UserData()
                    {
                        FirstName    = GetEncryptedString(firstname, eKey),
                        LastName     = GetEncryptedString(lastname, eKey),
                        LicenceKey   = licencekey,
                        SeatKey      = seatkey,
                        OptionalData = string.IsNullOrEmpty(optionaldata)? null : GetEncryptedString(optionaldata, eKey),
                        DeviceType   = devicetype,
                        DeviceModel  = devicemodel
                    });

                    return(Json(new
                    {
                        c = ResultCode.Success,
                        d = true
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        c = ResultCode.UserDataResultCodes.EkeyDoesntExist,
                        d = ""
                    }));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.GetLogText("userdataapi_adduserdata"));

                return(Json(new
                {
                    c = ResultCode.GenericException,
                    d = ex.Message
                }));
            }
        }