Ejemplo n.º 1
0
        /// <summary>
        /// Manages the opportunities in CRM.
        /// </summary>
        /// <param name="clientID">The client identifier.</param>
        /// <returns></returns>
        public ClientLoginDto ManageOpportunitiesInCRM(int clientID)
        {
            var client = new ClientLoginDto();

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingClient =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i => i.ClientID == clientID);

                    if (existingClient == null)
                    {
                        return(client);
                    }
                    else
                    {
                        client.CRMData          = existingClient.CRMData;
                        client.ManageOppysInCRM = (existingClient.ManageOppysInCRM == "Y");
                    }
                }
            }
            return(client);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <UserManagerResponse> > UserLogin([FromBody] ClientLoginDto clientLoginDto)
        {
            if (ModelState.IsValid)
            {
                var result = await _ClientService.LoginClientAsync(clientLoginDto);

                if (result.IsSuccessful)
                {
                    var UserInfo = await _ClientService.GetUserInfo(clientLoginDto.Email);

                    var cookieOptions = new CookieOptions()
                    {
                        HttpOnly = true,
                        SameSite = SameSiteMode.None,
                        Expires  = DateTime.Now.AddDays(30)
                    };
                    Response.Cookies.Append("LoginJwt", result.Message, cookieOptions);
                    result.Message = JsonConvert.SerializeObject(UserInfo);
                    return(Ok(result));
                }

                return(BadRequest());
            }
            return(BadRequest("Some properties are not valid"));
        }
Ejemplo n.º 3
0
        public ClientLoginDto GetClientSyncValues(int clientID)
        {
            ClientLoginDto client = new ClientLoginDto();

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var crmXrefUpdDT =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i => i.ClientID == clientID);

                    //verify this

                    /*client.CorsProSyncInd     = crmXrefUpdDT.CorsProSyncInd;
                     * client.SyncServerLocation = crmXrefUpdDT.SyncServerLocation;
                     * client.SyncServerLogin    = crmXrefUpdDT.SyncServerLogin;
                     * client.SyncServerPwd      = crmXrefUpdDT.SyncServerPwd;
                     * client.OpportunityMgmt    = (crmXrefUpdDT.OpportunityMgmt);
                     * client.LastSDAVer         = crmXrefUpdDT.LastSDAVer;
                     * client.LastSDAVerWithDBUpdates = crmXrefUpdDT.LastSDAVerWithDBUpdates;*/
                    return(client);
                }
            }
        }
Ejemplo n.º 4
0
        public static bool LoginUser(string username, string password)
        {
            ClientLoginDto clog = new ClientLoginDto {
                KIme_Mail = username, Sifra = password
            };

            try
            {
                SesijaDto sesija = Api.LoginUser(clog);
                MSettings.CurrentSession = new Session()
                {
                    SessionID = sesija.IdSesije
                };

                KorisnikFullDto korisnik = Api.GetUserFullInfo(sesija.IdKorisnika);
                if (korisnik.IdTipaNaloga == (int)User.UserAccountType.Student)
                {
                    MUtility.ShowError("Prijavljivanje sa studentskog naloga je onemoguceno na ovoj aplikaciji!");
                    Api.LogoutUser(MSettings.CurrentSession.SessionID);
                    return(false);
                }
                MSettings.CurrentSession.LoggedUser = MUtility.GenerateUserFromDTO(korisnik);
                return(true);
            }
            catch (Exception ex)
            {
                MSettings.CurrentSession = null;
                MUtility.ShowException(ex);
                return(false);
            }
        }
 public ClientDto GetByUsernameAndPassword(ClientLoginDto model)
 {
     return(_mapper.Map <ClientDto>(
                _context.Clients
                .Include(x => x.Cards)
                .Single(x => (x.Username == model.Username) && (x.Password == model.Password))
                ));
 }
        public async Task <UserManagerResponse> LoginClientAsync(ClientLoginDto model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("The model is null");
            }

            var user = await _UserManager.FindByEmailAsync(model.Email);

            if (user == null)
            {
                return(new UserManagerResponse
                {
                    IsSuccessful = false,
                    Message = "There is no user with this email found",
                });
            }

            var result = await _UserManager.CheckPasswordAsync(user, model.Password);

            if (!result)
            {
                return(new UserManagerResponse
                {
                    IsSuccessful = false,
                    Message = "Invalid Password",
                });
            }

            var claims = new[]
            {
                new Claim("Email", model.Email),
                new Claim(ClaimTypes.NameIdentifier, user.Id)
            };
            var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_Configurations["AuthSettings:Key"]));

            var token = new JwtSecurityToken(
                issuer: _Configurations["AuthSettings:Issuer"],
                audience: _Configurations["AuthSettings:Audience"],
                claims: claims,
                expires: DateTime.Now.AddDays(30),
                signingCredentials: new SigningCredentials(key, SecurityAlgorithms.HmacSha256)
                );

            string tokenAsString = new JwtSecurityTokenHandler().WriteToken(token);



            return(new UserManagerResponse
            {
                IsSuccessful = true,
                Message = tokenAsString,
                ExpireDate = token.ValidTo
            });
        }
Ejemplo n.º 7
0
        public Response <ClientTokenDto> CreateTokenByCleint(ClientLoginDto clientLoginDto)
        {
            var client = _clients.SingleOrDefault(x => x.Id == clientLoginDto.CleintId && x.Secret == clientLoginDto.ClientSecret);

            if (client == null)
            {
                return(Response <ClientTokenDto> .Fail("ClientId or Secret not found", 404, true));
            }
            var token = _tokenService.CreateTokenByClient(client);

            return(Response <ClientTokenDto> .Success(token, 200));
        }
        public Response <ClientTokenDto> CreateTokenByClient(ClientLoginDto clientLoginDto)
        {
            var _Client = clients.SingleOrDefault(x => x.Id == clientLoginDto.ClientId && x.Secret == clientLoginDto.ClientSecret);

            if (_Client == null)
            {
                return(Response <ClientTokenDto> .Fail("client bulunamadı", 404, true));
            }
            var token = tokenService.CreateToken(_Client);

            return(Response <ClientTokenDto> .Success(token, 200));
        }
Ejemplo n.º 9
0
        private void PozoviApiFunkciju()
        {
            ClientLoginDto clog = new ClientLoginDto
            {
                KIme_Mail = FindViewById <TextView>(Resource.Id.usernameText).Text,
                Sifra     = FindViewById <TextView>(Resource.Id.passwordText).Text
            };

            try
            {
                SesijaDto sesija = Api.Api.LoginUser(clog);
                MSettings.CurrentSession = new Session()
                {
                    SessionID = sesija.IdSesije
                };

                KorisnikFullDto korisnik = Api.Api.GetUserFullInfo(sesija.IdKorisnika);
                if (korisnik.IdTipaNaloga == (int)User.UserAccountType.Student)
                {
                    //if (!Api.LogoutUser(MSettings.CurrentSession.SessionID))
                    //    throw new Exception("Neuspesno ciscenje logovanja");
                    var intent = new Intent(this, typeof(MainSwipePage));
                    intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);
                    StartActivity(intent);

                    alert.Dismiss();

                    MSettings.CurrentSession.LoggedUser = MUtility.User_From_KorisnikFullDto(korisnik);

                    if (check.Checked)
                    {
                        ZapamtiKorisnika(clog.KIme_Mail, clog.Sifra);
                    }

                    this.Finish();
                }
                else
                {
                    alert.Dismiss();
                    MSettings.CurrentSession = null;
                    //Toast.MakeText(this, "Ovo nije korisnicki nalog!", ToastLength.Short).Show();
                    RunOnUiThread(() => Toast.MakeText(this, "Ovo nije korisnicki nalog!", ToastLength.Short).Show());
                }
            }
            catch (Exception ex)
            {
                alert.Dismiss();
                MSettings.CurrentSession = null;
                //Toast.MakeText(this, ex.Message, ToastLength.Short).Show();
                RunOnUiThread(() => Toast.MakeText(this, "Nepravilno korisnicko ime ili lozinka!", ToastLength.Short).Show());
            }
        }
Ejemplo n.º 10
0
        public ResponseModel <ClientTokenDto> CreateTokenByClient(ClientLoginDto clientLoginDto)
        {
            var client = _clients.SingleOrDefault(p => p.Id.Equals(clientLoginDto.ClientId, StringComparison.OrdinalIgnoreCase) && p.Secret.Equals(clientLoginDto.ClientSecret, StringComparison.OrdinalIgnoreCase));

            if (client == null)
            {
                return(ResponseModel <ClientTokenDto> .Fail("Client id or ClientSecret not found!", 404, true));
            }

            var token = _tokenService.CreateTokenByClient(client);

            return(ResponseModel <ClientTokenDto> .Success(token, 200));
        }
Ejemplo n.º 11
0
        public Response Authenticate(ClientLoginDto pClientLoginDto)
        {
            var response      = new Response();
            var clientLoginBL = new ClientLoginBL();

            if (clientLoginBL.ValidateClientLogin(pClientLoginDto))
            {
                response.Results.Add("Authenticated");
            }
            else
            {
                response.Errors.Add("Invalid authentication info");
            }
            return(response);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Validates the client login.
        /// </summary>
        /// <param name="clientLogin">The client login.</param>
        /// <returns></returns>
        public bool ValidateClientLogin(ClientLoginDto clientLogin)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingClient =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i =>
                            i.ClientLoginID == clientLogin.ClientLoginId &&
                            i.ClientLoginPwd == clientLogin.ClientLoginPwd);

                    return(existingClient != null);
                }
            }
        }
Ejemplo n.º 13
0
        public static SesijaDto LoginUser(ClientLoginDto loginData)
        {
            RestRequest request = new RestRequest(Method.POST);

            request.Resource = "korisnici/prijava";
            request.AddObject(loginData);

            ApiResponse <SesijaDto> response = Execute <SesijaDto>(request, false);

            if (!(response.HttpStatusCode == HttpStatusCode.OK || response.HttpStatusCode == HttpStatusCode.Redirect))
            {
                throw new Exception("LoginUser: Neispravno korisnicko ime ili lozinka" + "\nServerResponse: "
                                    + response.ErrorResponse + "\nHttpStatus: " + response.HttpStatusCode);
            }

            return(response.ResponseObject);
        }
Ejemplo n.º 14
0
        public IActionResult CreateTokenByClient(ClientLoginDto clientLoginDto)
        {
            var result = _authenticationService.CreateTokenByClient(clientLoginDto);

            return(ActionResultInstance(result));
        }
Ejemplo n.º 15
0
        public IActionResult CreateTokenByClient(ClientLoginDto clientLoginDto)
        {
            var tokenDto = _authenticationService.CreateTokenByClient(clientLoginDto);

            return(ActionResultInstance <ClientTokenDto>(tokenDto));
        }
Ejemplo n.º 16
0
 public ActionResult <ClientDto> GetByUsernameAndPassword(ClientLoginDto model)
 {
     return(_clientService.GetByUsernameAndPassword(model));
 }
Ejemplo n.º 17
0
        public Response AddSdaCloudOpportunity(List <OpportunityDto> opportunities)
        {
            Response      response = new Response();
            OpportunityDL ydl      = new OpportunityDL();
            ClientLoginDL ndl      = new ClientLoginDL();

            foreach (OpportunityDto dto in opportunities)
            {
                string str;
                try
                {
                    bool           manageOpportunitiesInCRM = false;
                    ClientLoginDto dto2 = ndl.ManageOpportunitiesInCRM(dto.ClientID);
                    if (dto2.ManageOppysInCRM)
                    {
                        manageOpportunitiesInCRM = dto2.ManageOppysInCRM;
                    }
                    int oppID = ydl.AddOpportunity(dto, manageOpportunitiesInCRM);
                    if (oppID < 0)
                    {
                        str = "ADD-SDACloud Duplicated record with Quote Id Main Site:" + dto.QuoteIDMainSite + ", could not be added";
                        if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)))
                        {
                            response.Results.Add(str);
                        }
                    }
                    else if (oppID <= 0)
                    {
                        str = "ADD-SDACloud CRM Opportunity Id:" + dto.CRMOppID + ", could not be added";
                        if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)))
                        {
                            response.Results.Add(str);
                        }
                        else
                        {
                            response.Errors.Add(str);
                        }
                    }
                    else if (!manageOpportunitiesInCRM && string.IsNullOrEmpty(dto.CRMOppID))
                    {
                        string[] strArray = new string[] { "ADD-SDACloud CRM Opportunity Id:", ydl.GetNonDeletedOpportunityByClientIDAndOppID(dto.ClientID, oppID).CRMOppID, ":Quote Id Main Site:", dto.QuoteIDMainSite, ", has been successfully added" };
                        str = string.Concat(strArray);
                        response.Results.Add(str);
                        this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto));
                    }
                    else if (!string.IsNullOrEmpty(dto.CRMOppID))
                    {
                        str = "ADD-SDACloud CRM Opportunity Id:" + dto.CRMOppID + ", has been successfully added";
                        response.Results.Add(str);
                        this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto));
                    }
                    else
                    {
                        str = "ADD-SDACloud Opportunity with Quote Id Main Site:" + dto.QuoteIDMainSite + ", has been successfully added";
                        response.Results.Add(str);
                        this._applicationLogDL.AddTransactionMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto));
                    }
                }
                catch (Exception exception)
                {
                    string[] strArray2 = new string[] { "SDACloud CRM Opportunity Id:", dto.CRMOppID, ":Quote Id Main Site:", dto.QuoteIDMainSite, ",", exception.Message, (exception.InnerException != null) ? exception.InnerException.Message : "" };
                    str = string.Concat(strArray2);
                    if (this._applicationLogDL.AddErrorMessage(dto.ClientID, str, this._utilityBl.ConvertRecordToString(dto)))
                    {
                        response.Results.Add(str);
                        continue;
                    }
                    response.Errors.Add(str);
                }
            }
            return(response);
        }
        public static SesijaDto PrijavaKorisnika(ClientLoginDto cdto)
        {
            ISession s = SesijeProvajder.Sesija;

            List <Korisnik> korisnici = s.Query <Korisnik>().Select(k => k).ToList();

            /*
             * List<Korisnik> ko = (from k in korisnici
             *  where k.KorisnickoIme == cdto.KIme_Mail
             || k.Email == cdto.KIme_Mail
             || select k).ToList();
             ||
             ||if (ko.Count != 1)
             || return null;
             ||
             ||if (ko[0].Sifra != cdto.Sifra)
             || return null;
             ||
             ||if (ko[0].Obrisan)
             || return null;
             ||
             ||if (!ko[0].AktivanNalog)
             || return null;
             */

            Korisnik ko = korisnici.Find(x => x.KorisnickoIme == cdto.KIme_Mail ||
                                         x.Email == cdto.KIme_Mail);

            if (ko == null)
            {
                return(null);
            }

            if (ko.Obrisan)
            {
                return(null);
            }

            if (!ko.AktivanNalog)
            {
                return(null);
            }

            if (ko.Sifra != cdto.Sifra)
            {
                return(null);
            }

            LoginSesija sesija = new LoginSesija()
            {
                KorisnikSesije      = ko,
                IdSesije            = Guid.NewGuid().ToString(),
                DatumPrijavljivanja = DateTime.Now,
                ValidnaDo           = DateTime.Now.AddYears(1)
            };

            s.Save(sesija);
            s.Flush();

            SesijaDto sdto = new SesijaDto()
            {
                IdSesije            = sesija.IdSesije,
                IdKorisnika         = sesija.KorisnikSesije.IdKorisnika,
                DatumPrijavljivanja = sesija.DatumPrijavljivanja,
                ValidnaDo           = sesija.ValidnaDo
            };

            return(sdto);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Validates the client login.
        /// </summary>
        /// <param name="clientLogin">The client login.</param>
        /// <returns></returns>
        public bool ValidateClientLogin(ClientLoginDto clientLogin)
        {
            var clientLoginDl = new ClientLoginDL();

            return(clientLoginDl.ValidateClientLogin(clientLogin));
        }