コード例 #1
0
ファイル: DomainController.cs プロジェクト: Debadatt/LGSE
        public async Task <IHttpActionResult> PostDomain(DomainRequest item)
        {
            // Mapper.Reset();
            try
            {
                ValidationUtilities.ValidateDomain(item);
                string currentUserEmail = HttpUtilities.GetUserNameFromToken(this.Request);
                Mapper.Initialize(cfg => cfg.CreateMap <DomainRequest, Domain>().ForMember(i => i.CreatedBy,
                                                                                           j => j.UseValue(currentUserEmail)));
                var domain = Mapper.Map <DomainRequest, Domain>(item);
                domain.Id = Guid.NewGuid().ToString();
                Domain current = await InsertAsync(domain);

                return(CreatedAtRoute("Tables", new { id = current.Id }, current));
            }
            catch (HttpResponseException ex)
            {
                LGSELogger.Error(ex);
                throw ex;
            }
        }