Backend works Log

Update Multiple Records Request object 

public class UpdateCampaignRuleRequest

    {

        public List<BbReferralCampaignRule> Items { get; set; }

        public UpdateCampaignRuleRequest()

        {

            this.Items = new List<BbReferralCampaignRule>();

        }

    }

------------------------------------

Mapper

 public class MappingProfile : Profile

    {

        public MappingProfile()

        {

            CreateMap<AddCampaignRuleRequest, BbReferralCampaignRule>();

        }

    }

-----------

in startup.cs - > ConfigureServices.cs 

 AppStartup.ConfigureAutoMapperServices(services);


in startup.cs - separate method

 public static void ConfigureAutoMapperServices(IServiceCollection services)

        {

            MapperConfiguration oMapperConfiguration = new MapperConfiguration(mc =>

            {

                mc.AddProfile(new MappingProfile());

                mc.AddMaps(System.Reflection.Assembly.GetAssembly(typeof(CoreLib.MappingProfile)));

                mc.AddMaps(System.Reflection.Assembly.GetAssembly(typeof(GameLib.MappingProfile)));

            });

            IMapper mapper = oMapperConfiguration.CreateMapper();

            services.AddSingleton(mapper);

        }

Authorize in Admin

- Get Bearer token from UI 


- paste it in postman as below




----------------------------------------------------

Common Response Class

* For a List of Response

 public class DbFetchListResponse<T>

    {

        public bool IsSuccess { get; set; }

        public string SpResponse { get; set; }

        public int SpResponseId { get; set; }

        public List<T> FetchedObjects { get; set; }

        public DbFetchListResponse()

        {

            this.IsSuccess = false;

            this.SpResponseId = 0;

            this.SpResponse = "";

        }

        public static DbFetchListResponse<T> GetSuccessInstance(List<T> fetchedObjects)

        {

            DbFetchListResponse<T> retu = new DbFetchListResponse<T>()

            {

                IsSuccess = true,

                FetchedObjects = fetchedObjects

            };

            return retu;

        }

        public static DbFetchListResponse<T> GetFailureInstance(int spResponseId, string spResponse)

        {

            DbFetchListResponse<T> retu = new DbFetchListResponse<T>()

            {

                IsSuccess = false,

                SpResponseId = spResponseId,

                SpResponse = spResponse

            };

            return retu;

        }

    }


* For Single Response 

 public class DbFetchSingleResponse<T>

    {

        public bool IsSuccess { get; set; }

        public string SpResponse { get; set; }

        public int SpResponseId { get; set; }

        public T FetchedObject { get; set; }

        public DbFetchSingleResponse()

        {

            this.IsSuccess = false;

            this.SpResponseId = 0;

            this.SpResponse = "";

        }

        public static DbFetchSingleResponse<T> GetSuccessInstance(T fetchedObject)

        {

            DbFetchSingleResponse<T> retu = new DbFetchSingleResponse<T>()

            {

                IsSuccess = true,

                FetchedObject = fetchedObject

            };

            return retu;

        }

        public static DbFetchSingleResponse<T> GetFailureInstance(int spResponseId, string spResponse)

        {

            DbFetchSingleResponse<T> retu = new DbFetchSingleResponse<T>()

            {

                IsSuccess = false,

                SpResponseId = spResponseId,

                SpResponse = spResponse

            };

            return retu;

        }

        public static DbFetchSingleResponse<T> GetFailureDefaultInstance()

        {

            DbFetchSingleResponse<T> retu = new DbFetchSingleResponse<T>()

            {

                IsSuccess = false,

                SpResponseId = -1,

                SpResponse = "Initialization Ready"

            };

            return retu;

        }

    }


-----------------------------------------------------

ADD DATABASE TO .Net Core Api

1. appsettings.json

        "BBRAF": "Data Source=bbcoreproddb-for-dev.c50i89cgjfpz.eu-west-1.rds.amazonaws.com;User Id=themasterofDISASTER;password=worker!do!work;Initial Catalog=BBRAF;Persist Security Info=True;Trusted_Connection=False;MultipleActiveResultSets=true;Connect Timeout=5"


2.Interface & Implementatin

3.Startup.cs

ConfigureServices  method-  > services.AddDb<RafDbContext>("BBRAF");  
                                            ->  services.AddScoped<IRafRepository, RafRepository>();


4.Controller






----------------------------------------

PostToSlack

public async Task PostToSlack(string to, string text, string sender)

        {

            const string baseUrl = "https://hooks.slack.com";

            const string resource = "/services/TCCNN7EA3/B010DCQHP4P/okglEraeX2dazqIEviH44TeN";


            await _HttpClient.PostAsync($"{baseUrl}{resource}", new StringContent(GeneralLib.JsonHelper.Serialize(

                new

                {

                    blocks = new List<dynamic>

                    {

                        new

                        {

                            type = "section",

                            text = new

                            {

                                type = "mrkdwn",

                                text = $"*{sender} delivered to {to}*"

                            }

                        },

                        new

                        {

                            type = "section",

                            text = new

                            {

                                type = "mrkdwn",

                                text = $"```{text}```"

                            }

                        }

                    }

                })));

        }


ToUniversalTime

   

      DateTime localDate, universalDate,frmt1;

            String str = "11/11/2019 4:10:55";

            localDate = DateTime.Now;

            universalDate = localDate.ToUniversalTime();

            Console.WriteLine("Local time = {0} ", localDate);

            Console.WriteLine("Universal time = {0} ", universalDate);


---------------------------

 Add all works here done by you or you know 


Add jwt  refresh token

Git commit with bbcommon 

- commit bbcommon first 

- then commit main api with bbcommon submodule update

---------------------------

Comments

Popular posts from this blog

tech note

Vue js Standalone