Exemple #1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var Client = new ClientsModel
                {
                    Name        = collection["name"],
                    LastName    = collection["LastName"],
                    Phone       = int.Parse(collection["Phone"]),
                    Description = collection["Description"]
                };

                if (Client.Save())
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(Client));
                }
            }
            catch
            {
                return(View());
            }
        }
        public ClientsModel Get()
        {
            ClientsModel clientList = new ClientsModel();

            foreach (var client in clientProviderService.Clients)
            {
                if (client.IsAreaServer)
                {
                    AreaServerModel model = AreaServerModel.ConvertDate(client);
                    if (model != null)
                    {
                        clientList._areaServerList.Add(model);
                    }
                }
                else
                {
                    PlayerModel model = PlayerModel.ConvertData(client);
                    if (model != null)
                    {
                        clientList.PlayerList.Add(model);
                    }
                }
            }

            return(clientList);
        }
        public List <ClientsModel> GetClientDetails()
        {
            string cs   = CONNECTIONSTRING;
            var    conn = new NpgsqlConnection(cs);

            conn.Open();

            string        sql = @"SELECT * FROM clients";
            NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);

            NpgsqlDataReader dr = cmd.ExecuteReader();
            var clients         = new List <ClientsModel>();

            while (dr.Read())
            {
                var clientModel = new ClientsModel
                {
                    ClientId  = dr.GetInt32(0),
                    FirstName = dr.GetString(1)
                };
                clients.Add(clientModel);
            }

            conn.Close();
            return(clients);
        }
Exemple #4
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Checker())
     {
         if (txtClientID.Text != "")
         {
             ClientsModel client = new ClientsModel(
                 Convert.ToInt32(txtClientID.Text),
                 txtFirstName.Text,
                 txtLastName.Text,
                 txtBarcode.Text,
                 txtPhoneNumber.Text,
                 Convert.ToDecimal(txtDiscount.Text)
                 );
             SqliteDataAccess.EditClient(client);
         }
         else
         {
             ClientsModel client = new ClientsModel(
                 txtFirstName.Text,
                 txtLastName.Text,
                 txtBarcode.Text,
                 txtPhoneNumber.Text,
                 Convert.ToDecimal(txtDiscount.Text),
                 0
                 );
             SqliteDataAccess.CreateClient(client);
         }
         form.Refresh();
         this.Close();
     }
 }
Exemple #5
0
        public static void AddClient(ClientsModel model, ServicesModel ModelServices, int postedbyId)
        {
            DataContext     db              = new DataContext();
            TblClient       tbl             = new TblClient();
            TblBusinessType tblBusinessType = new TblBusinessType();

            tbl.Name = model.Name;

            tbl.TypeOfCompany       = model.TypeOfCompany;
            tbl.LimitedBy           = model.LimitedBy;
            tbl.ShareValue1         = model.ShareValue1;
            tbl.ShareValue2         = model.ShareValue2;
            tbl.ShareCapitalProduct = model.ProductOfShareValues;
            tbl.BusinessObjectives  = model.BusinessObjectives;
            tbl.CNIC = model.CNIC;

            tbl.NTN         = model.NTN;
            tbl.PINCode     = model.PINCode;
            tbl.FBRLogin    = model.FBRLogin;
            tbl.FBRPassword = model.FBRPassword;

            tbl.IncorporationNo = model.IncorporationNo;
            tbl.RegistrationNo  = model.RegistrationNo;
            tbl.RegisteredWith  = model.RegisteredWith;
            tbl.Address         = model.Address;
            tbl.Email           = model.Email;
            tbl.PhoneNo         = model.PhoneNo;
            tbl.MobileNo        = model.MobileNo;
            tbl.FaxNo           = model.FaxNo;
            tbl.CreatedById     = postedbyId;
            tbl.CreatedDate     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            tbl.IsActive        = true;
            db.TblClients.InsertOnSubmit(tbl);

            db.SubmitChanges();

            TblService tblServices = new TblService();
            var        res         = (from c in db.TblClients
                                      orderby c.Id descending
                                      select c).FirstOrDefault();

            tbl = res;
            int currentClientId = tbl.Id;

            tblServices.ClientId = currentClientId;

            tblBusinessType.BusinessType = model.BusinessType;
            tblBusinessType.ClientId     = currentClientId;
            tblServices.Accounting       = true ? ModelServices.Accounting == "Accounting" : false;
            tblServices.Audit            = true ? ModelServices.Audit == "Audit" : false;
            tblServices.Legal            = true ? ModelServices.Legal == "Legal" : false;
            tblServices.Taxation         = true ? ModelServices.Taxation == "Taxation" : false;
            tblServices.Corporate        = true ? ModelServices.Corporate == "Corporate" : false;

            db.TblBusinessTypes.InsertOnSubmit(tblBusinessType);
            db.TblServices.InsertOnSubmit(tblServices);
            db.SubmitChanges();
            db.Dispose();
            //UpdateAndSaveService( ModelServices, currentClientId);
        }
Exemple #6
0
        public ActionResult Index()
        {
            ClientsModel model = null;

            try
            {
                CheckUserAuthorization();
            }
            catch
            {
                ViewBag.Logged   = false;
                ViewBag.UserName = Session["UserName"];
                ViewBag.Error    = "Access denied. Please log in.";
                return(View(model));
            }

            ViewBag.Logged = true;
            try
            {
                IEnumerable <ClientModel> clients = ClientsProvider.GetAllClients();
                model = new ClientsModel()
                {
                    Clients = clients.ToList()
                };
            }
            catch (Exception ex)
            {
                //TODO log
                ViewBag.Error = $"Unable to load clients: {ex.Message}";
            }
            return(View(model));
        }
Exemple #7
0
        public string EnterNewClient(Car car)
        {
            var code = "";

            try
            {
                ClientsModel client = new ClientsModel
                {
                    id     = car.brand.Substring(0, 1) + car.model.Substring(0, 1) + car.plates,
                    brand  = car.brand,
                    model  = car.model,
                    plates = car.plates,
                    enter  = DateTime.Now,
                    exit   = null
                };
                clientsModels.Add(client);
                SaveChangesAsync();
                code = client.id;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(code);
        }
        public IHttpActionResult login([FromBody] Client clientobj)
        {
            HandelErrorObject <ClientsModel> handelError = new HandelErrorObject <ClientsModel>();
            ClientsModel client = db.Clients.Where(c => c.email == clientobj.email).Where(c => c.password == clientobj.password).ToList().Select(c => mf.create(c)).FirstOrDefault();

            if (client != null)
            {
                string  Clientjson = JsonConvert.SerializeObject(client);
                JObject jo         = JObject.Parse(Clientjson);
                jo.Property("password").Remove();
                ClientsModel ClientCon = jo.ToObject <ClientsModel>();

                handelError.data    = ClientCon;
                handelError.status  = true;
                handelError.message = "";
                return(Ok(handelError));
            }
            else
            {
                handelError.data = null;
                var message = string.Format("Email or Password incorrect");
                handelError.status  = false;
                handelError.message = message;
                return(Ok(handelError));
            }
        }
Exemple #9
0
 public static void CreateClient(ClientsModel client)
 {
     using (IDbConnection cnn = new MySqlConnection(LoadConnectionString()))
     {
         cnn.Execute("INSERT INTO clients (ClientFirstName, ClientLastName, ClientBarcode, ClientPhone, ClientDiscount, ClientBought) " +
                     "VALUES (@ClientFirstName, @ClientLastName, @ClientBarcode, @ClientPhone, @ClientDiscount, @ClientBought)", client);
     }
 }
        private void InitClients()
        {
            var json = System.IO.File.ReadAllText(Environment.CurrentDirectory + @"\Clients\ClientList.json");

            clientsModel           = JsonConvert.DeserializeObject <ClientsModel>(json);
            cbClient.DataSource    = clientsModel.Clients;
            cbClient.DisplayMember = "Name";
            cbClient.ValueMember   = "Id";
        }
        public ActionResult Index()
        {
            ClientsModel clients = new ClientsModel();

            clients.clients     = clientBusiness.getClients();
            clients.utilisateur = GetChefFromCookie();

            return(View(clients));
        }
        // OAuthAuthorizationServerProvider sınıfının client erişimine izin verebilmek için ilgili ValidateClientAuthentication metotunu override ediyoruz.
        //public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        //{
        //    context.Validated();
        //    return Task.FromResult<object>(null);
        //}

        // OAuthAuthorizationServerProvider sınıfının kaynak erişimine izin verebilmek için ilgili GrantResourceOwnerCredentials metotunu override ediyoruz.
        //public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        //{
        //    // CORS ayarlarını set ediyoruz.
        //    context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

        //    _kullanici = await _kullanicilarService.GetKullanicilarByKullaniciAdiAsync(context.UserName);
        //    if (_kullanici == null)
        //    {
        //        context.SetError("invalid_grant", "Sistemde kayıtlı böyle bir kullanıcı bulunmamaktadır.");
        //        return;
        //    }

        //    if (_kullanici != null)
        //    {
        //        byte[] salt = Convert.FromBase64String(_kullanici.Salt);

        //        byte[] passwordSaltedHash = Utility.Hash(context.Password, salt);

        //        if (Convert.ToBase64String(passwordSaltedHash).Equals(_kullanici.SifreHash, StringComparison.InvariantCulture))
        //        {
        //            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
        //            identity.AddClaim(new Claim("userName", _kullanici.KullaniciAdi));
        //            identity.AddClaim(new Claim("email", _kullanici.Email));
        //            identity.AddClaim(new Claim("userID", _kullanici.Id.ToString()));

        //            context.Validated(identity);
        //            context.Request.Context.Authentication.SignIn(identity);
        //        }
        //        else
        //            context.SetError("invalid_grant", "Kullanıcı adı veya şifre yanlış.");
        //    }
        //}

        //public override Task TokenEndpointResponse(OAuthTokenEndpointResponseContext context)
        //{
        //    var accessToken = context.AccessToken;
        //    _kullanicilarService.InsertKullaniciOturumAsync(new KullaniciOturumModel
        //    {
        //        AuthToken = context.AccessToken,
        //        KullaniciId = _kullanici.Id,
        //        SonlanmaTarihi = DateTime.Now.AddMinutes(2)
        //    });

        //    return Task.FromResult<object>(null);
        //}
        #endregion

        #region v.2.0.0
        //public override async Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
        //{
        //    //if (context.ClientId == Clients.Client1.Id)
        //    //{
        //    //    context.Validated(Clients.Client1.RedirectUrl);
        //    //}
        //    //else if (context.ClientId == Clients.Client2.Id)
        //    //{
        //    //    context.Validated(Clients.Client2.RedirectUrl);
        //    //}
        //    //return Task.FromResult(0);
        //}

        /// <summary>
        /// ValidateClientAuthentication
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            //context.Validated();
            string clientId;
            string clientSecret;

            _logger.Debug(GetType(), null, "Checking clientId & clientSecret");
            if (!context.TryGetBasicCredentials(out clientId, out clientSecret))
            {
                context.TryGetFormCredentials(out clientId, out clientSecret);
            }

            _logger.Debug(GetType(), null, "Is ClientId null");
            if (context.ClientId == null)
            {
                context.SetError("invalid_clientId", "ClientId parametre olarak gönderilmelidir.");
                return;
            }

            _logger.Debug(GetType(), null, "GetByClientIdAsync({0})", context.ClientId);
            _client = await _clientService.GetByClientIdAsync(context.ClientId);

            if (_client == null)
            {
                context.SetError("invalid_clientId", string.Format("Sistemde kayıtlı böyle bir client bulunmamaktadır.", context.ClientId));
                return;
            }

            //Client Secret ile işlem yapılmak istenirse açılmalıdır.
            //if (_client.ApplicationType == ApplicationTypes.WebDevelopment)
            //{
            //    if (string.IsNullOrWhiteSpace(clientSecret))
            //    {
            //        context.SetError("invalid_clientId", "Client secret should be sent.");
            //        return Task.FromResult<object>(null);
            //    }
            //    else
            //    {
            //        if (client.Secret != Helper.GetHash(clientSecret))
            //        {
            //            context.SetError("invalid_clientId", "Client secret is invalid.");
            //            return Task.FromResult<object>(null);
            //        }
            //    }
            //}

            if (!_client.Active)
            {
                context.SetError("invalid_clientId", "Client aktif değildir.");
                return;
            }

            context.OwinContext.Set <string>("as:clientAllowedOrigin", _client.AllowedOrigin);
            context.OwinContext.Set <string>("as:clientRefreshTokenLifeTime", _client.RefreshTokenLifeTime.ToString());

            context.Validated();
        }
Exemple #13
0
        public bool checkLogin(ClientsModel model)
        {
            using (var context = new TravelAgencyEntities())
            {
                bool isvalid = context.tbl_Clients.Any(x => x.Username == model.Username && x.Password == model.Password);

                return(isvalid);
            }
        }
 public ClientController()
 {
     fileStorage          = new FileStorage();
     ClientsModel         = new ClientsModel();
     ClientsView          = new Clients(ClientsModel.GetAll());
     clientParametersView = new ClientParametesView();
     LoadClientsModel();//загрузка даннных в модель
     ClientsView.RefreshList(ClientsModel.GetAll());
     Listen();
 }
Exemple #15
0
 public ActionResult Edit([Bind(Include = "Id,Password,EmailId,FirstName,LastName,MobileNo,Address,City,State")] ClientsModel clientsModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientsModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientsModel));
 }
Exemple #16
0
        public ActionResult Clients()
        {
            if (HttpContext.Session["lngId"] == null)
            {
                HttpContext.Session["lngId"] = 1;
            }
            ClientsModel model = HomeBuilder.BuildClients(Db);

            ViewBag.Link = 3;
            return(View(model));
        }
Exemple #17
0
 public static void EditClient(ClientsModel client)
 {
     using (IDbConnection cnn = new MySqlConnection(LoadConnectionString()))
     {
         cnn.Execute("UPDATE clients SET ClientFirstName = @ClientFirstName, " +
                     "ClientLastName = @ClientLastName, " +
                     "ClientPhone = @ClientPhone, " +
                     "ClientDiscount = @ClientDiscount, " +
                     "ClientBought = @ClientBought " +
                     "WHERE ClientID = @ClientID ", client);
     }
 }
Exemple #18
0
        public Task UpdateAsync(ClientsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("Client ArgumentNullException Insert Async");
            }

            Clients dto = AutoMapperGenericHelper <ClientsModel, Clients> .Convert(model);

            _clientRepository.Update(dto);

            return(Task.FromResult <object>(null));
        }
Exemple #19
0
        private void Clients_Load(object sender, EventArgs e)
        {
            num_countRowsOnPage.Value = Math.Round((decimal)dgv_client.Size.Height / dgv_client.RowTemplate.Height, 0, MidpointRounding.AwayFromZero) - 2;
            clientsModel = new ClientsModel((int)num_countRowsOnPage.Value);
            num_countRowsOnPage.Maximum = clientsModel.MaxRows;

            Fill_autoCompleteString();

            cmb_countVisit.SelectedIndex = 0;
            cmb_lastName.SelectedIndex   = 0;
            cmb_dateVisit.SelectedIndex  = 0;
            cmb_gender.SelectedIndex     = 0;
        }
Exemple #20
0
        public static void UpdatedClient(ClientsModel model, ServicesModel ModelServices, int postedbyId, int ClientId)
        {
            DataContext db = new DataContext();

            TblClient result = (from c in db.TblClients
                                where c.Id == ClientId
                                select c).Single();

            result.Name                = model.Name;
            result.TypeOfCompany       = model.TypeOfCompany;
            result.LimitedBy           = model.LimitedBy;
            result.BusinessObjectives  = model.BusinessObjectives;
            result.ShareValue1         = model.ShareValue1;
            result.ShareValue2         = model.ShareValue2;
            result.ShareCapitalProduct = model.ProductOfShareValues;
            result.CNIC                = model.CNIC;
            result.IncorporationNo     = model.IncorporationNo;
            result.RegistrationNo      = model.RegistrationNo;
            result.RegisteredWith      = model.RegisteredWith;
            result.Address             = model.Address;
            result.Email               = model.Email;
            result.PhoneNo             = model.PhoneNo;
            result.MobileNo            = model.MobileNo;
            result.FaxNo               = model.FaxNo;
            result.UpdatedById         = postedbyId;
            result.UpdatedDate         = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            db.SubmitChanges();

            /****************************************************************************************/

            TblService resultServices = (from s in db.TblServices
                                         where s.ClientId == ClientId
                                         select s).SingleOrDefault();

            resultServices.Accounting = true ? ModelServices.Accounting == "Accounting" : false;
            resultServices.Audit      = true ? ModelServices.Audit == "Audit" : false;
            resultServices.Legal      = true ? ModelServices.Legal == "Legal" : false;
            resultServices.Taxation   = true ? ModelServices.Taxation == "Taxation" : false;
            resultServices.Corporate  = true ? ModelServices.Corporate == "Corporate" : false;

            /***************************************************************************************/

            TblBusinessType resultBusinessType = (from b in db.TblBusinessTypes
                                                  where b.ClientId == ClientId
                                                  select b).SingleOrDefault();

            resultBusinessType.BusinessType = model.BusinessType;
            db.SubmitChanges();
            db.Dispose();
        }
        public ActionResult CreateClient(ClientsModel clientsModel)
        {
            try
            {
                _context.clients.Add(clientsModel);
                _context.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemple #22
0
        public ActionResult Create(ClientsModel clientsModel)
        {
            if (ModelState.IsValid)
            {
                var result = destinationRepository.AddClient(clientsModel);
                if (result > 0)
                {
                    ModelState.Clear();
                    return(RedirectToAction("Create"));
                }
            }

            return(View());
        }
        public ActionResult DeleteClient(int id, ClientsModel clientsModel)
        {
            try
            {
                var clientToDelete = _context.clients.Find(id);
                _context.clients.Remove(clientToDelete);
                _context.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemple #24
0
 public ActionResult Login(ClientsModel clientsModel)
 {
     if (ModelState.IsValid)
     {
         var result = destinationRepository.checkLogin(clientsModel);
         if (result)
         {
             FormsAuthentication.SetAuthCookie(clientsModel.Username, false);
             ModelState.Clear();
             return(RedirectToAction("Index", "Home"));
         }
     }
     ModelState.AddModelError("", "Invalid username or password");
     return(View());
 }
Exemple #25
0
        public ActionResult Clients()
        {
            var lngId = 1;

            if (Session["lngId"] != null)
            {
                lngId = (int)Session["lngId"];
            }


            ClientsModel model = HomeBuilder.BuildClients(Db);

            ViewBag.Link = 3;
            return(View(model));
        }
Exemple #26
0
        public Task <ClientsModel> GetByClientIdAsync(string clientId)
        {
            var dal = _clientRepository.GetByClientIdAsync(clientId);

            if (dal == null)
            {
                return(Task.FromResult <ClientsModel>(null));
            }
            else
            {
                ClientsModel model = AutoMapperGenericHelper <Clients, ClientsModel> .Convert(dal);

                return(Task.FromResult(model));
            }
        }
Exemple #27
0
        public static void SaveClientTax(ClientsModel model, int clientId)
        {
            DataContext db  = new DataContext();
            TblTax      tbl = new TblTax();

            tbl.UpdatedBy       = model.UpdatedById;
            tbl.FilePathNew     = model.FilePathNew;
            tbl.FilePathOld     = model.FilePathOld;
            tbl.ClientId        = clientId;
            tbl.UserId          = model.UserId;
            tbl.YearId          = model.YearId;
            tbl.LastChangesInfo = model.LastChanges;
            db.TblTaxes.InsertOnSubmit(tbl);
            db.SubmitChanges();
            db.Dispose();
        }
Exemple #28
0
        public ResponseModel <int> Post([FromBody] ClientsModel dataToAdd)
        {
            var resp = new ResponseModel <int>();

            try
            {
                if (dataToAdd == null)
                {
                    throw new Exception("Data is null");
                }

                var model = new Clients()
                {
                    Name     = dataToAdd.Name,
                    IsActive = dataToAdd.IsActive,
                    Creation = DateTime.Now,
                    Updated  = DateTime.Now,
                    IdGroup  = dataToAdd.IdGroup
                };

                IClientsRepository appRepo = new ClientsRepository(new DataBaseContext());

                if (appRepo.ExistByName(model.IdGroup, model.Name))
                {
                    throw new Exception("Client already exist");
                }

                if (appRepo.Insert(model))
                {
                    resp.Data        = model.Id;
                    resp.Status      = 200;
                    resp.Description = "OK";
                }
                else
                {
                    throw new Exception("Not inserted");
                }
            }
            catch (Exception ex)
            {
                resp.Status      = 500;
                resp.Description = $"Error: {ex.Message}";
                resp.Data        = 0;
            }

            return(resp);
        }
        public IHttpActionResult createUser(ClientsModel clientModel)
        {
            HandelErrorObject <Client> handelError = new HandelErrorObject <Client>();
            ClientsModel clientobj = db.Clients.Where(c => c.email == clientModel.email).ToList().Select(c => mf.create(c)).FirstOrDefault();

            try
            {
                if (clientobj == null)
                {
                    Client client = new Client();
                    client.Client_ID    = clientModel.Client_ID;
                    client.full_name    = clientModel.full_name;
                    client.email        = clientModel.email;
                    client.phone_number = clientModel.phone_number;
                    client.password     = clientModel.password;
                    client.cash         = clientModel.cash;
                    client.block        = clientModel.block;
                    client.points       = clientModel.points;
                    db.Clients.Add(client);
                    db.SaveChanges();

                    string  Clientjson = JsonConvert.SerializeObject(client);
                    JObject jo         = JObject.Parse(Clientjson);
                    jo.Property("password").Remove();
                    Client ClientCon = jo.ToObject <Client>();

                    handelError.data    = ClientCon;
                    handelError.status  = true;
                    handelError.message = "User created successfully";
                    return(Ok(handelError));
                }
                else
                {
                    handelError.data    = null;
                    handelError.status  = false;
                    handelError.message = "Email is used";
                    return(Ok(handelError));
                }
            }
            catch (Exception e)
            {
                handelError.data    = null;
                handelError.status  = false;
                handelError.message = e.Message;
                return(Ok(handelError));
            }
        }
        public IHttpActionResult Patch(ClientsModel client)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _clientService.UpdateAsync(client);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }