Example #1
0
        /// <summary>
        /// Local unit creation method
        /// </summary>
        /// <param name="data">Data</param>
        /// <param name="userId">User Id</param>
        /// <returns></returns>
        public async Task <Dictionary <string, string[]> > CreateLocalUnit(LocalUnitCreateM data, string userId)
        {
            var helper = new StatUnitCheckPermissionsHelper(_dbContext);

            helper.CheckRegionOrActivityContains(userId, data.Address?.RegionId, data.ActualAddress?.RegionId, data.PostalAddress?.RegionId, data.Activities.Select(x => x.ActivityCategoryId).ToList());

            return(await CreateUnitContext <LocalUnit, LocalUnitCreateM>(data, userId, null));
        }
Example #2
0
        public async Task <IActionResult> CreateLocalUnit([FromBody] LocalUnitCreateM data)
        {
            var result = await _createService.CreateLocalUnit(data, User.GetUserId());

            if (result != null && result.ContainsKey(nameof(UserAccess.UnauthorizedAccess)))
            {
                return(Forbid());
            }
            return(result == null ? (IActionResult)NoContent() : BadRequest(result));
        }