Example #1
0
        public async Task <IHttpActionResult> PostUserRoleMap(UserRoleMapRequest item)
        {
            try
            {
                ValidationUtilities.ValidateForUserRoleMap(item);
                string currentUserEmail = HttpUtilities.GetUserNameFromToken(this.Request);
                Mapper.Initialize(cfg => cfg.CreateMap <UserRoleMapRequest, UserRoleMap>().ForMember(i => i.CreatedBy,
                                                                                                     j => j.UseValue(currentUserEmail)));
                var userRoleMap = Mapper.Map <UserRoleMapRequest, UserRoleMap>(item);
                userRoleMap.Id = Guid.NewGuid().ToString();
                UserRoleMap current = await InsertAsync(userRoleMap);

                return(CreatedAtRoute("Tables", new { id = current.Id }, current));
            }
            catch (HttpResponseException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                HttpUtilities.ServerError(ex, Request);
                return(null);
            }
        }