Exemplo n.º 1
0
        public IActionResult Login([FromBody] AuthModel auth)
        {
            if (String.IsNullOrEmpty(auth.email) || String.IsNullOrEmpty(auth.password))
            {
                return(BadRequest("Invalid client request"));
            }
            if ((auth.email == "*****@*****.**" && auth.password == "amar123") || (_userProvider.GetInstance("")).validateUser("", auth).Result)
            {
                var      secretKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(SystemConstants.JWT));
                var      signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256);
                DateTime expiredIn         = DateTime.Now.AddMinutes(30);
                var      tokeOptions       = new JwtSecurityToken(
                    issuer: "https://localhost:44308",
                    audience: "https://localhost:44308",
                    claims: new List <Claim>(),
                    expires: expiredIn,
                    signingCredentials: signinCredentials
                    );

                var tokenString = new JwtSecurityTokenHandler().WriteToken(tokeOptions);
                return(Ok(new { Token = tokenString, Expires = expiredIn }));
            }
            else
            {
                return(Unauthorized());
            }
        }
Exemplo n.º 2
0
        public Feedback delete(string tenant, int id, int notificationid)
        {
            Feedback feedback = new Feedback();

            try
            {
                AppNotification notification;
                if (notificationid == 0)
                {
                    notification = new AppNotification()
                    {
                        type     = "Category",
                        message  = String.Format("Deleting category with id {0}", id),
                        progress = 0
                    };
                    _notificationRepo.GetInstance(tenant).save(ref notification);
                    _hubContext.Clients.All.SendAsync("SendNotification", notification);
                }
                else
                {
                    notification = _notificationRepo.GetInstance(tenant).getById(notificationid);
                }

                try
                {
                    if (_categoryRepo.GetInstance(tenant).delete(id))
                    {
                        notification.progress = 1;
                        notification.message  = "Data Deleted Successfully";
                        _notificationRepo.GetInstance(tenant).save(ref notification);
                        feedback = new Feedback
                        {
                            Code    = 1,
                            Message = notification.message,
                            data    = id
                        };
                        _hubContext.Clients.All.SendAsync("SendNotification", notification);
                    }
                }
                catch (Exception ex)
                {
                    notification.progress = -1;
                    notification.message  = "Got the error while removing data";
                    _notificationRepo.GetInstance(tenant).save(ref notification);
                    feedback = new Feedback
                    {
                        Code    = 0,
                        Message = "Got the error while removing data",
                        data    = ex
                    };
                    GitHub.createIssue(ex, new { id = id, tenant = tenant }, _accessor.HttpContext.Request.Headers);
                }
            }
            catch (Exception ex)
            {
                GitHub.createIssue(ex, new { id = id, tenant = tenant }, _accessor.HttpContext.Request.Headers);
            }
            return(feedback);
        }
Exemplo n.º 3
0
        public Feedback getSettings(string tenant)
        {
            Feedback feedback;

            try
            {
                var _userData = _generalRepo.GetInstance(tenant).getAppSettings();

                feedback = new Feedback
                {
                    Code    = 0,
                    Message = "Record Fetched Successfully",
                    data    = _userData
                };
            }
            catch (Exception ex)
            {
                feedback = new Feedback
                {
                    Code    = 0,
                    Message = "Got the error while removing data",
                    data    = ex
                };
                GitHub.createIssue(ex, new { tenant = tenant }, _accessor.HttpContext.Request.Headers);
            }
            return(feedback);
        }
Exemplo n.º 4
0
        public Feedback getById(string tenant, int id)
        {
            Feedback feedback;

            try
            {
                var _productData = _productRepo.GetInstance(tenant).getById(id);
                if (_productData != null)
                {
                    var _productCategoryData = _productCategoryRepo.GetInstance(tenant).getByProductId(id);
                    _productData.categories = _productCategoryData;
                    feedback = new Feedback
                    {
                        Code    = 1,
                        Message = "Data fetched sucessfully",
                        data    = _productData
                    };
                }
                else
                {
                    feedback = new Feedback
                    {
                        Code    = 0,
                        Message = "Record not found",
                        data    = null
                    };
                }
            }
            catch (Exception ex)
            {
                feedback = new Feedback
                {
                    Code    = 0,
                    Message = "Got the error while retriving data",
                    data    = ex
                };
                GitHub.createIssue(ex, new { id = id, tenant = tenant }, _accessor.HttpContext.Request.Headers);
            }
            return(feedback);
        }
Exemplo n.º 5
0
 public async Task <Feedback> GetName(int id, string tenant = "")
 {
     return(await _userProvider.GetInstance(tenant).getName(tenant, id));
 }
Exemplo n.º 6
0
 public Feedback ImportExcel(ImportExcel fileName, string tenant = "")
 {
     return(_importExcelProvider.GetInstance(tenant).ImportCategoryExcel(tenant, fileName));
 }
Exemplo n.º 7
0
 public CategoryController(IServicesProvider <ICategoryService> categoryProvider)
 {
     _categoryProvider = categoryProvider.GetInstance();
 }
Exemplo n.º 8
0
 public Feedback GetSettings(string tenant = "")
 {
     return(_generalProvider.GetInstance(tenant).getSettings(tenant));
 }
Exemplo n.º 9
0
 public CategoryController(IServicesProvider <ICategoryService> _service)
 {
     service = _service.GetInstance();
 }
Exemplo n.º 10
0
 public Feedback GetName(int id, string tenant = "")
 {
     return(_productProvider.GetInstance(tenant).getName(tenant, id));
 }
Exemplo n.º 11
0
 public Feedback Save(AppNotification data, string tenant = "")
 {
     return(_notifyProvider.GetInstance(tenant).save(tenant, data));
 }
 public string Get(string tenant)
 {
     return(_tenantServiceProvider.GetInstance(tenant).GetName());
 }