コード例 #1
0
        public App()
        {
            SystemConfigurationModel systemConfigurations = systemConfigurationController.GetSystemConfiguration().FirstOrDefault();

            Settings.FinalYearStartDate = systemConfigurations?.FinalYearStartDate;
            Settings.FinalYearEndDate   = systemConfigurations?.FinalYearEndDate;
        }
コード例 #2
0
        public IHttpActionResult UpdateSystemConfiguration(int id, [FromBody] SystemConfigurationModel.Format_Update dataModel)
        {
            string logForm = "Form : " + JsonConvert.SerializeObject(dataModel);
            string logAPI  = "[Patch] " + Request.RequestUri.ToString();

            if (!ModelState.IsValid || dataModel == null)
            {
                Global._appLogger.Warn(logAPI + " || Input Parameter not expected || " + logForm);
                return(Content(HttpStatusCode.BadRequest, HttpResponseFormat.InvaildData()));
            }

            try
            {
                SystemConfigurationModel model = new SystemConfigurationModel();
                model.Update(id, dataModel);

                return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
            }
            catch (CDSException cdsEx)
            {
                return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = LogHelper.BuildExceptionMessage(ex);
                logMessage.AppendLine(logForm);
                Global._appLogger.Error(logAPI + logMessage);

                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }
コード例 #3
0
        public IHttpActionResult GetAllSystemConfiguration()
        {
            int companyId = Global.GetCompanyIdFromToken();
            SystemConfigurationModel model = new SystemConfigurationModel();

            return(Content(HttpStatusCode.OK, model.GetAll(companyId)));
        }
コード例 #4
0
        public ActionResult ManageSystemConfigurations(SystemConfigurationModel model)
        {
            var user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();

            if (ModelState.IsValid)
            {
                SystemConfiguration mscobj = dobj.SystemConfiguration.FirstOrDefault();

                mscobj.EmailID1 = model.EmailID1;

                mscobj.PhoneNumber = model.PhoneNumber;
                mscobj.EmailID2    = model.EmailID2;
                mscobj.FacebookUrl = model.FacebookURL;
                mscobj.TwitterUrl  = model.TwitterURL;
                mscobj.LinkedInUrl = model.LinkedInURL;
                mscobj.CreatedBy   = user.ID;
                mscobj.CreatedDate = DateTime.Now;

                if (model.DefaultNotePreview != null)
                {
                    var      OldDefaultNoteImage = Server.MapPath(mscobj.DefaultNotePreview);
                    FileInfo file = new FileInfo(OldDefaultNoteImage);
                    if (file.Exists)
                    {
                        file.Delete();
                    }
                    var DefaultNoteImageName     = "defaultbook" + Path.GetExtension(model.DefaultNotePreview.FileName);
                    var DefaultNoteImageSavePath = Path.Combine(Server.MapPath("~/Content/Default/") + DefaultNoteImageName);
                    model.DefaultNotePreview.SaveAs(DefaultNoteImageSavePath);
                    mscobj.DefaultNotePreview = Path.Combine(("~/Content/Default/") + DefaultNoteImageName);
                }

                if (model.DefaultProfilePicture != null)
                {
                    var      OldDefaultProfilePicture = Server.MapPath(mscobj.DefaultProfilePicture);
                    FileInfo file2 = new FileInfo(OldDefaultProfilePicture);
                    if (file2.Exists)
                    {
                        file2.Delete();
                    }
                    var DefaultProfilePictureName     = "defaultuser" + Path.GetExtension(model.DefaultProfilePicture.FileName);
                    var DefaultProfilePictureSavePath = Path.Combine(Server.MapPath("~/Content/Default/") + DefaultProfilePictureName);
                    model.DefaultProfilePicture.SaveAs(DefaultProfilePictureSavePath);
                    mscobj.DefaultProfilePicture = Path.Combine(("~/Content/Default/") + DefaultProfilePictureName);
                }
                dobj.Entry(mscobj).State = System.Data.Entity.EntityState.Modified;
                dobj.SaveChanges();

                return(RedirectToAction("Dashboard", "Admin"));
            }
            return(View());
        }
コード例 #5
0
 public IHttpActionResult GetSystemConfigurationById(int id)
 {
     try
     {
         SystemConfigurationModel model = new SystemConfigurationModel();
         return(Content(HttpStatusCode.OK, model.GetById(id)));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
コード例 #6
0
 public IHttpActionResult DeleteSystemConfiguration(int id)
 {
     try
     {
         SystemConfigurationModel model = new SystemConfigurationModel();
         model.DeleteById(id);
         return(Content(HttpStatusCode.OK, HttpResponseFormat.Success()));
     }
     catch (CDSException cdsEx)
     {
         return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
     }
     catch (Exception ex)
     {
         string        logAPI     = "[Delete] " + Request.RequestUri.ToString();
         StringBuilder logMessage = LogHelper.BuildExceptionMessage(ex);
         Global._appLogger.Error(logAPI + logMessage);
         return(Content(HttpStatusCode.InternalServerError, ex));
     }
 }
コード例 #7
0
        public ActionResult ManageSystemConfigurations()
        {
            var emailid = User.Identity.Name.ToString();

            NotesMarketPlace.Context.Users admin = dobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            SystemConfiguration sct = dobj.SystemConfiguration.FirstOrDefault();

            SystemConfigurationModel model = new SystemConfigurationModel();

            model.EmailID1 = sct.EmailID1;

            model.PhoneNumber = sct.PhoneNumber;
            model.EmailID2    = sct.EmailID2;
            model.FacebookURL = sct.FacebookUrl;
            model.TwitterURL  = sct.TwitterUrl;
            model.LinkedInURL = sct.LinkedInUrl;

            ViewBag.ProfilePicture = dobj.AdminDetail.Where(x => x.AdminID == admin.ID).Select(x => x.ProfilePicture).FirstOrDefault();
            return(View(model));
        }
コード例 #8
0
ファイル: Startup.cs プロジェクト: efonsecab/BlazorRestaurant
        /// <summary>
        /// Configured application services
        /// </summary>
        /// <param name="services"></param>

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            GlobalPackageConfiguration.RapidApiKey = Configuration["PTIMicroservicesLibraryConfiguration:RapidApiKey"];

            var azureAdB2CSection = Configuration.GetSection("AzureAdB2C");

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddMicrosoftIdentityWebApi(azureAdB2CSection);
            services.Configure <JwtBearerOptions>(
                JwtBearerDefaults.AuthenticationScheme, options =>
            {
                options.TokenValidationParameters.NameClaimType = "name";
                options.TokenValidationParameters.RoleClaimType = "Role";
                options.Events.OnTokenValidated = async(context) =>
                {
                    BlazorRestaurantDbContext blazorRestaurantDbContext = CreateBlazorRestaurantDbContext(services);
                    ClaimsIdentity claimsIdentity = context.Principal.Identity as ClaimsIdentity;
                    var userObjectIdClaim         = claimsIdentity.Claims.Single(p => p.Type == Shared.Global.Constants.Claims.ObjectIdentifier);
                    var user = await blazorRestaurantDbContext.ApplicationUser
                               .Include(p => p.ApplicationUserRole)
                               .ThenInclude(p => p.ApplicationRole)
                               .Where(p => p.AzureAdB2cobjectId.ToString() == userObjectIdClaim.Value)
                               .SingleOrDefaultAsync();
                    if (user != null && user.ApplicationUserRole != null)
                    {
                        claimsIdentity.AddClaim(new Claim("Role", user.ApplicationUserRole.ApplicationRole.Name));
                    }
                };
                options.SaveToken = true;
            });

            services.AddTransient <ILogger <CustomHttpClientHandler>, CustomHttpClientHandlerLogger>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped <ICurrentUserProvider, CurrentUserProvider>();
            services.AddScoped(serviceProvide =>
            {
                BlazorRestaurantDbContext blazorRestaurantDbContext = CreateBlazorRestaurantDbContext(serviceProvide);
                return(blazorRestaurantDbContext);
            });

            services.AddAutoMapper(configAction =>
            {
                configAction.AddMaps(new[] { typeof(Startup).Assembly });
            });

            SystemConfigurationModel systemConfiguration =
                Configuration.GetSection("SystemConfiguration").Get <SystemConfigurationModel>();

            services.AddSingleton(systemConfiguration);
            ConfigureDataStorage(services);
            ConfigurePTIMicroservicesLibraryDefaults(services);
            ConfigureAzureBlobStorage(services);

            AzureConfiguration azureConfiguration = Configuration.GetSection("AzureConfiguration").Get <AzureConfiguration>();

            services.AddSingleton(azureConfiguration);

            ConfigureAzureMaps(services, azureConfiguration);

            services.AddControllersWithViews();
            services.AddRazorPages();

            services.AddSwaggerGen(c =>
            {
                c.UseInlineDefinitionsForEnums();
                var filePath = Path.Combine(System.AppContext.BaseDirectory, "BlazorRestaurant.Server.xml");
                if (System.IO.File.Exists(filePath))
                {
                    c.IncludeXmlComments(filePath);
                }
            });
        }
コード例 #9
0
 /// <summary>
 /// Creates a new instance of <see cref="ConfigurationController"/>
 /// <paramref name="azureConfiguration"/>
 /// <paramref name="systemConfiguration"/>
 /// </summary>
 public ConfigurationController(AzureConfiguration azureConfiguration, SystemConfigurationModel systemConfiguration)
 {
     this.AzureConfiguration  = azureConfiguration;
     this.SystemConfiguration = systemConfiguration;
 }