Ejemplo n.º 1
0
        public IActionResult Update([FromBody] List <dto_Settings> settings)
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            if (settings != null && settings.Count > 0)
            {
                if (ModelState.IsValid)
                {
                    foreach (var item in settings)
                    {
                        dto_Settings _old = _service_Settings.Get(item.ID);
                        _old.Conf_Value = item.Conf_Value;
                        _service_Settings.update(_old);
                    }
                }
                else
                {
                    _res.FillError("model state is invalid");
                    _log.Error("model state is invalid");
                }
            }
            else
            {
                _res.FillError("setting is null");
                _log.Error("setting is null");
            }
            return(Ok(_res));
        }
Ejemplo n.º 2
0
        public IActionResult Update([FromBody] dto_GridSettings settings)
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            if (settings != null)
            {
                if (ModelState.IsValid)
                {
                    FillBase(settings);
                    settings.UserID = CurrentUser.ID;
                    dto_GridSettings _old = _service_Settings.GetValue(settings.Key, CurrentUser.ID);
                    if (_old != null)
                    {
                        _old.Value = settings.Value;
                        _service_Settings.update(_old);
                    }
                    else
                    {
                        _service_Settings.update(settings);
                    }
                }
                else
                {
                    _res.FillError("model state is invalid");
                    _log.Error("model state is invalid");
                }
            }
            else
            {
                _res.FillError("setting is null");
                _log.Error("setting is null");
            }
            return(Ok(_res));
        }
Ejemplo n.º 3
0
        public IActionResult Update_old([FromBody] dto_Settings settings)
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            if (settings != null)
            {
                if (ModelState.IsValid)
                {
                    dto_Settings _old = _service_Settings.Get(settings.ID);
                    _old.Conf_Value = settings.Conf_Value;
                    _service_Settings.update(_old);
                }
                else
                {
                    _res.FillError("model state is invalid");
                    _log.Error("model state is invalid");
                }
            }
            else
            {
                _res.FillError("setting is null");
                _log.Error("setting is null");
            }
            return(Ok(_res));
        }
Ejemplo n.º 4
0
        public IActionResult ForgotPassword([FromBody] dto_User model)
        {
            GenericResponse res = new GenericResponse();

            res.FillSuccess();
            if (model != null && !string.IsNullOrEmpty(model.Email))
            {
                var olduser = _service_account.GetUser(model.Email);
                if (olduser != null)
                {
                    _emailHelper.AddToAddress(model.Email);
                    _emailHelper.Subject = "Reset Password";
                    _emailHelper.Body    = "Kindly find your password as following : " + olduser.Password;
                    _emailHelper.SendMail();
                }
                else
                {
                    res.FillError();
                }
            }
            else
            {
                res.FillError();
            }



            return(Ok(res));
        }
Ejemplo n.º 5
0
        public IActionResult update([FromBody] dto_User user)
        {
            GenericResponse res = new GenericResponse();

            res.FillSuccess();
            _profileService.update(user);
            return(Ok(res));
        }
        public IActionResult Get()
        {
            GenericResponse res = new GenericResponse();

            res.FillSuccess();
            res.data = _userTypeService.Get();
            return(Ok(res));
        }
Ejemplo n.º 7
0
        public IActionResult load()
        {
            GenericResponse res = new GenericResponse();

            res.FillSuccess();
            res.data = _profileService.load(CurrentUser.ID);

            return(Ok(res));
        }
Ejemplo n.º 8
0
        // DELETE api/<controller>/5
        public IActionResult Delete([FromBody] dto_Privillige Model)
        {
            GenericResponse response = new GenericResponse();

            response.FillSuccess();
            _service_Privillige.Remove(Model);
            response.data = Model;
            return(Ok(response));
        }
Ejemplo n.º 9
0
        // POST api/<controller>
        public IActionResult CreateMultiple([FromBody] CreateMultipleViewModel Users)
        {
            GenericResponse response = new GenericResponse();
            List <string>   Errors   = new List <string>();

            if (ModelState.IsValid)
            {
                response.FillSuccess();
                if (Users != null && Users.users != null && Users.users.Count > 0)
                {
                    foreach (var Model in Users.users)
                    {
                        try
                        {
                            fillservices();
                            FillBase(Model.Model);
                            if (_service_account.validate(Model.Model))
                            {
                                Model.Model.Groups      = Model.Groups_Selected;
                                Model.Model.Privilliges = Model.Privilliges_Selected;
                                _service_User.CreateOREdit(Model.Model);
                                //response.data = Model;
                            }
                            else
                            {
                                Errors.Add(Model.Model.Email + "Already Exist");
                                response.FillError(Model.Model.Email + "Already Exist");
                            }
                        }
                        catch (Exception ex)
                        {
                            Errors.Add(ex.Message);
                            response.FillError(ex);
                        }
                    }
                }
                else
                {
                    response.FillError("Empty users");
                }
            }
            else
            {
                response.FillError("Model state is not valid");
            }
            if (Errors.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var item in Errors)
                {
                    sb.AppendLine(item);
                }
                response.FillError(sb.ToString());
            }
            return(Ok(response));
        }
Ejemplo n.º 10
0
        public IActionResult Getall()
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            var Keys = _service_Settings.Getall();

            _res.data = Keys;
            return(Ok(_res));
        }
Ejemplo n.º 11
0
        public IActionResult Get(string Key)
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            dto_GridSettings _old = _service_Settings.GetValue(Key, CurrentUser.ID);

            _res.data = _old;
            return(Ok(_res));
        }
Ejemplo n.º 12
0
        // GET api/<controller>/5
        public IActionResult Get(Guid ID)
        {
            GenericResponse response = new GenericResponse();

            response.FillSuccess();
            var Model = _service_Privillige.Get(ID);

            response.data = Model;
            return(Ok(response));
        }
Ejemplo n.º 13
0
        // DELETE api/<controller>/5
        public IActionResult SearchActiveDirectory([FromQuery] string UserName)
        {
            GenericResponse response = new GenericResponse();

            response.FillSuccess();
            var res = _helper_activeDirectory.Search(UserName);

            response.data = res;
            return(Ok(response));
        }
Ejemplo n.º 14
0
        public IActionResult Getall()
        {
            GenericResponse response      = new GenericResponse();
            GetPageResponse _Pageresponse = new GetPageResponse();

            response.FillSuccess();
            int totalCount = 0;
            var PageModel  = _service_Privillige.GetPage(1, int.MaxValue, out totalCount);

            _Pageresponse.totalCount = totalCount;
            _Pageresponse.PageModel  = PageModel;
            response.data            = _Pageresponse;
            return(Ok(response));
        }
Ejemplo n.º 15
0
        public IActionResult GetPaged(int page, int pagesize)
        {
            GenericResponse response      = new GenericResponse();
            GetPageResponse _Pageresponse = new GetPageResponse();

            response.FillSuccess();
            int totalCount = 0;
            var PageModel  = _service_Group.GetPage(page, pagesize, out totalCount).ToList();

            _Pageresponse.totalCount = totalCount;
            _Pageresponse.PageModel  = PageModel;
            response.data            = _Pageresponse;
            return(Ok(response));
        }
Ejemplo n.º 16
0
        public IActionResult ChangePassword([FromBody] ChangePasswordVM model)
        {
            GenericResponse res = new GenericResponse();

            res.FillSuccess();
            if (model != null && model.confirmPassword == model.password && !string.IsNullOrEmpty(model.password))
            {
                _service_account.ChangePassword(CurrentUser.ID, model.password);
            }
            else
            {
                res.FillError();
            }
            return(Ok(res));
        }
Ejemplo n.º 17
0
        public IActionResult ChangePassword([FromBody] LoginViewModel Model)
        {
            GenericResponse response = new GenericResponse();

            response.FillSuccess();
            if (Model != null && !string.IsNullOrEmpty(Model.Password))
            {
                _service_User.ChangePassword(CurrentUser.ID, Model.Password);
            }
            else
            {
                response.FillError("password Is empty");
            }
            return(Ok(response));
        }
Ejemplo n.º 18
0
        // DELETE api/<controller>/5
        public IActionResult Validate([FromBody] LoginViewModel Model)
        {
            GenericResponse response = new GenericResponse();

            response.FillSuccess();
            if (ModelState.IsValid)
            {
                var res = _helper_activeDirectory.Validate(Model.Username, Model.Password);
                response.data = res;
            }
            else
            {
                response.FillError("UserName Is empty");
            }
            return(Ok(response));
        }
        public IActionResult ChangeArabic()
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            try
            {
                string _token = base.GetTokenForArabic();
                _res.data = _token;
            }
            catch (Exception ex)
            {
                _res.FillError("Failed");
            }
            return(Ok(_res));
        }
Ejemplo n.º 20
0
        // POST api/<controller>
        public IActionResult Create([FromBody] dto_Privillige Model)
        {
            GenericResponse response = new GenericResponse();

            if (ModelState.IsValid)
            {
                response.FillSuccess();
                FillBase(Model);
                _service_Privillige.CreateOREdit(Model);
                response.data = Model;
            }
            else
            {
                response.FillError();
            }
            return(Ok(response));
        }
Ejemplo n.º 21
0
        public IActionResult register([FromBody] RegisterModel input)
        {
            GenericResponse response = new GenericResponse();

            response.FillSuccess();
            FillBase(input.User);

            if (_service_account.validate(input.User))
            {
                input.User.isActivated         = true;
                input.User.ActivationStartDate = DateTime.Now;
                _service_account.register(input.User);
            }
            else
            {
                response.FillError("Already Exist");
            }
            return(Ok(response));
        }
        public IActionResult GetMenuItems()
        {
            GenericResponse res = new GenericResponse();

            res.FillSuccess();
            var MenuItems = _service_Menu.GetMenuItems();

            FilterPrivilligedMenu(MenuItems);
            GetOnlyParentsMenu(MenuItems);

            //var MenuView = Mapper.Map<List<MenuItemViewModel>>(MenuItems);
            foreach (var item in MenuItems)
            {
                RemoveEmptyChildObject(item);
            }
            res.data = MenuItems;

            return(Ok(res));
        }
Ejemplo n.º 23
0
        // POST api/<controller>
        public IActionResult Create([FromBody] dto_Group Model)
        {
            GenericResponse response = new GenericResponse();

            if (ModelState.IsValid)
            {
                //Model.Model.Privilliges = Model.Privilliges_Selected;
                response.FillSuccess();
                //FillBase(Model.Model);
                FillBase(Model);

                //_service_Group.CreateOREdit(Model.Model);
                _service_Group.CreateOREdit(Model);
                response.data = Model;
            }
            else
            {
                response.FillError();
            }
            return(Ok(response));
        }
Ejemplo n.º 24
0
        // POST api/<controller>
        public IActionResult Create([FromBody] dto_User Model)
        {
            GenericResponse response = new GenericResponse();

            if (ModelState.IsValid)
            {
                response.FillSuccess();
                FillBase(Model);
                if (_service_account.validate(Model))
                {
                    _service_User.CreateOREdit(Model);
                    response.data = Model;
                }
                else
                {
                    response.FillError("Already Exist");
                }
            }
            else
            {
                response.FillError();
            }
            return(Ok(response));
        }
Ejemplo n.º 25
0
        public IActionResult Login([FromBody] dto_User input)
        {
            GenericResponse _res = new GenericResponse();

            _res.FillSuccess();
            if (input != null)
            {
                var user = _service_account.GetUser(input.Email);

                if (user != null)
                {
                    if (user.isAD)
                    {
                        var valid = _helper_activeDirectory.Validate(input.Email, input.Password);
                        if (valid)
                        {
                            user = _service_account.loginAD(input.Email);
                        }
                        else
                        {
                            user = null;
                            _res.FillError("User NotFound");
                        }
                    }
                    else if (input.IsThirdParty)
                    {
                        user = _service_account.login(input.Email);
                    }
                    else
                    {
                        user = _service_account.login(input.Email, input.Password);
                    }
                }
                else
                {
                    if (input.IsThirdParty)
                    {
                        FillBase(input);
                        input.ActivationStartDate = DateTime.Now;
                        input.isActivated         = true;

                        _service_account.register(input);
                        user = _service_account.login(input.Email);
                    }
                    else
                    {
                        _res.FillError("User NotFound");
                    }
                }
                if (user != null)
                {
                    if (user.isActivated && user.ActivationStartDate.HasValue && user.ActivationStartDate.Value <= DateTime.Now &&
                        (user.ActivationEndDate.HasValue == false || user.ActivationEndDate <= DateTime.Now)
                        )
                    {
                        UserTokenModel model = new UserTokenModel();
                        model.IsEnglish = true;
                        emptyUser(user);
                        model.User = user;
                        string token = GenerateToken_HS256(model);
                        //string token = GenerateToken_RS256(user);
                        //string Decoded = decodeToken_RS256(token);
                        _res.data = token;
                    }
                    else
                    {
                        _res.FillError("User is not activated");
                    }
                    return(Ok(_res));
                }
                else
                {
                    _res.FillError("User NotFound");
                    return(Ok(_res));
                }
            }
            else
            {
                _res.FillError("User NotFound");
                return(Ok(_res));
            }
        }