public ProviderDTO GetProviderContactById(long ProviderId) { command = new SqlCommand(StoredProcedureName.Names.GetProviderContactById.ToString(), connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@ProviderID", SqlDbType.BigInt); command.Parameters[0].Value = ProviderId; connection.Open(); datareader = command.ExecuteReader(); if (!datareader.HasRows) { return(null); } while (datareader.Read()) { provider = new ProviderDTO(); provider.ProviderId = Convert.ToInt64(datareader["ProviderId"]); provider.Address1 = datareader["Address1"].ToString(); provider.Address2 = datareader["Address2"].ToString(); provider.Email = datareader["Email"].ToString(); provider.Phone = datareader["Phone"].ToString(); provider.Fax = datareader["Fax"].ToString(); provider.Website = datareader["Website"].ToString(); provider.Mobile = datareader["Mobile"].ToString(); //provider.Country = datareader["Country"].ToString(); } connection.Close(); return(provider); }
public ProviderDTO GetProviderPassword(long providerid) { command = new SqlCommand(StoredProcedureName.Names.GetProviderPassword.ToString(), connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@ProviderId", SqlDbType.BigInt); command.Parameters[0].Value = providerid; connection.Open(); datareader = command.ExecuteReader(); connection.Open(); if (!datareader.HasRows) { return(null); } while (datareader.Read()) { provider = new ProviderDTO(); provider.Email = datareader["Email"].ToString(); provider.Password = datareader["Password"].ToString(); } connection.Close(); return(provider); }
public long AuthenticateUser(ProviderDTO provider) { command = new SqlCommand(StoredProcedureName.Names.AuthenticateUser.ToString(), connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Email", SqlDbType.VarChar); command.Parameters.Add("@Password", SqlDbType.VarChar); command.Parameters[0].Value = provider.Email; command.Parameters[1].Value = provider.Password; connection.Open(); datareader = command.ExecuteReader(); if (datareader.HasRows) { datareader.Read(); return(Convert.ToInt64(datareader["ProviderId"].ToString())); } else { return(0); } }
public long InsertProvider(ProviderDTO Provider) { command = new SqlCommand(StoredProcedureName.Names.AddProvider.ToString(), connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@FirstName", SqlDbType.VarChar, 50); command.Parameters.Add("@LastName", SqlDbType.VarChar, 50); command.Parameters.Add("@Country", SqlDbType.VarChar, 50); command.Parameters.Add("@UserName", SqlDbType.VarChar, 50); command.Parameters.Add("@Password", SqlDbType.VarChar, 50); command.Parameters[0].Value = Provider.FirstName; command.Parameters[1].Value = Provider.LastName; command.Parameters[2].Value = Provider.Country; command.Parameters[3].Value = Provider.Email; command.Parameters[4].Value = Provider.Password; long providerid = 0; connection.Open(); providerid = Convert.ToInt64(command.ExecuteScalar()); connection.Close(); return(providerid); }
public ProviderDTO GetProviderIntroductionById(long ProviderId) { command = new SqlCommand(StoredProcedureName.Names.GetProviderIntroductionById.ToString(), connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@ProviderID", SqlDbType.BigInt); command.Parameters[0].Value = ProviderId; connection.Open(); datareader = command.ExecuteReader(); if (!datareader.HasRows) { return(null); } while (datareader.Read()) { provider = new ProviderDTO(); provider.ProviderId = Convert.ToInt64(datareader["ProviderId"]); provider.FirstName = datareader["FirstName"].ToString(); provider.LastName = datareader["LastName"].ToString(); provider.MiddleName = datareader["MiddleName"].ToString(); provider.Haves = datareader["Haves"].ToString(); provider.Wants = datareader["Wants"].ToString(); provider.OverView = datareader["Overview"].ToString(); provider.Country = datareader["Country"].ToString(); } connection.Close(); return(provider); }
public async Task Update(ProviderDTO provider) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = _options.ConnectionString; SqlCommand command = new SqlCommand(); command.CommandText = "UPDATE PROVIDERS SET FANTASYNAME = @FANTASYNAME, EMAIL = @EMAIL,CNPJ = @CNPJ PHONE = @PHONE, ISACTIVE = @ISACTIVE WHERE ID = @ID"; command.Parameters.AddWithValue("@ID", provider.ID); command.Parameters.AddWithValue(@"FANTASYNAME", provider.FantasyName); command.Parameters.AddWithValue(@"EMAIL", provider.Email); command.Parameters.AddWithValue(@"PHONE", provider.Phone); Response response = new Response(); try { await connection.OpenAsync(); int idGerado = Convert.ToInt32(command.ExecuteScalar()); } catch (Exception ex) { response.Errors.Add("Erro no banco de dados, contate o administrador!"); File.WriteAllText("log.txt", ex.Message); } finally { await connection.CloseAsync(); } }
public void UpdateDTO(ProviderDTO providerDTO) { if (providerDTO.Contacts != null) { if (providerDTO.Contacts.ContactsId > 0) { _unit.ContactsRepository.Update(_mapper.Map <Contact>(providerDTO.Contacts)); } else { var contacts = _unit.ContactsRepository.Get(); if (contacts.Any()) { int maxContactId = contacts.Max(x => x.ContactsId); providerDTO.Contacts.ContactsId = maxContactId + 1; } else { providerDTO.Contacts.ContactsId = 1; } _unit.ContactsRepository.Add(_mapper.Map <Contact>(providerDTO.Contacts)); } } _unit.AddressesRepository.Update(providerDTO.Address); var provider = _mapper.Map <Provider>(providerDTO); provider.AddressId = providerDTO.Address.AddressId; provider.ContactId = providerDTO?.Contacts.ContactsId; provider.Services = null; _unit.ProvidersRepository.Update(provider); _unit.Submit(); }
public int UpdateProviderIntroducation(ProviderDTO Provider) { command = new SqlCommand(StoredProcedureName.Names.UpdateProviderIntroducation.ToString(), connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@ProviderId", SqlDbType.BigInt); command.Parameters.Add("@FirstName", SqlDbType.VarChar, 50); command.Parameters.Add("@LastName", SqlDbType.VarChar, 50); command.Parameters.Add("@MiddleName", SqlDbType.VarChar, 50); command.Parameters.Add("@Haves", SqlDbType.VarChar); command.Parameters.Add("@Wants", SqlDbType.VarChar); command.Parameters.Add("@OverView", SqlDbType.VarChar); command.Parameters.Add("@Country", SqlDbType.VarChar); command.Parameters[0].Value = Provider.ProviderId; command.Parameters[1].Value = Provider.FirstName; command.Parameters[2].Value = Provider.LastName; command.Parameters[3].Value = Provider.MiddleName; command.Parameters[4].Value = Provider.Haves; command.Parameters[5].Value = Provider.Wants; command.Parameters[6].Value = Provider.OverView; command.Parameters[7].Value = Provider.Country; int rowaffected = 0; connection.Open(); rowaffected = command.ExecuteNonQuery(); connection.Close(); return(rowaffected); }
protected void BtnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { provider = new ProviderDTO(); providerbl = new ProviderBL(); provider.FirstName = TxtFirstName.Text.ToString(); provider.LastName = TxtLastName.Text.ToString(); provider.UserName = TxtUserName.Text.ToString(); provider.Email = TxtUserName.Text.ToString(); provider.Password = TxtPassword.Text.ToString(); provider.Country = DdlCountry.SelectedItem.Text; providerId = providerbl.InsertProvider(provider); if (providerId != -1) { cookie = new HttpCookie("Freelancing"); cookie.Values.Add("ProviderId", providerId.ToString()); cookie.Values.Add("UserName", provider.UserName); cookie.Values.Add("Password", provider.Password); Response.SetCookie(cookie); Response.Redirect("~/Default.aspx"); } else { LblNameExist.Visible = true; } } }
protected void btnRegisterClient_Click(object sender, EventArgs e) { try { ProviderDTO providerDTO = new ProviderDTO(); ProviderBLL providerBLL = new ProviderBLL(); providerDTO.Name = txtRegisterName.Text; providerDTO.Cnpj = txtRegisterCnpj.Text; providerDTO.Email = txtRegisterEmail.Text; providerDTO.Phone = txtRegisterPhone.Text; providerDTO.RepresentativeName = txtRegisterRepresentativeName.Text; providerDTO.RepresentativePhone = txtRegisterRepresentativePhone.Text; string clientId = providerBLL.ReturnID(providerDTO.Email); if (clientId == "NOT_FOUND") { providerBLL.Insert(providerDTO); clientId = providerBLL.ReturnID(providerDTO.Email); string msg = string.Format($@"Seja bem vindo ao nosso sistema '{providerDTO.Name}'"); SuccessMessage(msg); Response.Redirect("adminProvider.aspx"); } else { string msg = string.Format($@"Não foi possível finalizar o cadastro. Já existe um usuário com o e-mail: '{providerDTO.Email}'"); ErrorMessage(msg); } } catch (Exception error) { ErrorMessage(error.Message); } }
protected void BtnChangePassword_Click(object sender, EventArgs e) { provider = new ProviderDTO(); providerbl = new ProviderBL(); bool passwordchanged = false; provider.ProviderId = Master.ProviderId; provider.Password = TxtOldPassword.Text; passwordchanged = providerbl.ChangePassword(provider, TxtNewPassword.Text); if (passwordchanged == true) { TxtNewPassword.Text = ""; TxtOldPassword.Text = ""; TxtRetypePassword.Text = ""; LblPasswordChanged.Visible = true; LblPasswordChanged.Text = "Password Changed"; LblPasswordChanged.ForeColor = System.Drawing.Color.Black; } else { LblPasswordChanged.Visible = true; LblPasswordChanged.Text = "Password Not Changed"; LblPasswordChanged.ForeColor = System.Drawing.Color.Red; } }
protected void Page_Load(object sender, EventArgs e) { GetCookie(); provider = new ProviderDTO(); providerbl = new ProviderBL(); }
public async Task <IActionResult> Insert(ProviderInsertViewModel viewmodel) { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <ProviderInsertViewModel, ProviderDTO>(); }); IMapper mapper = configuration.CreateMapper(); // new SERService().GetSERByID(4); //Transforma o ClienteInsertViewModel em um ClienteDTO ProviderDTO dto = mapper.Map <ProviderDTO>(viewmodel); ProviderService svc = new ProviderService(); try { await svc.Insert(dto); return(RedirectToAction("Index", "Category")); } catch (Exception ex) { ViewBag.Erros = ex.Message; } return(View()); }
private ProviderDTO ConvertProviderModelToProviderDTO(ProviderModel model) { try { ProviderDTO providerDto = new ProviderDTO() { Id = model.Id, Email = model.Email, Info = model.Info, IsActive = model.IsActive, IsFavorite = model.IsFavorite, Name = model.Name, Path = model.Path.Replace(_path, ""), TimeWorkTo = Convert.ToDateTime(model.TimeWorkTo), TimeWorkWith = Convert.ToDateTime(model.TimeWorkWith), WorkingDays = model.WorkingDays }; return(providerDto); } catch (Exception ex) { return(null); } }
public ProviderDTO GetProvider(int?id) { if (id == null) { throw new ValidationException("Не установлено id поставщика", ""); } var provider = Database.Provider.Get(id.Value); if (provider == null) { throw new ValidationException("Поставщик не найден", ""); } ProviderDTO providerDTO = new ProviderDTO() { Id = provider.Id, WorkingDays = provider.WorkingDays, Email = provider.Email, Info = provider.Info, IsActive = provider.IsActive, IsFavorite = provider.IsFavorite, Name = provider.Name, Path = provider.Path, TimeWorkTo = provider.TimeWorkTo, TimeWorkWith = provider.TimeWorkWith }; return(providerDTO); }
public void Change(ProviderDTO providerDTO) { var provider = Map(providerDTO); db.Providers.Update(provider); db.Save(); }
public Provider Post([FromBody] ProviderDTO value) { TryValidateModel(value); var provider = this.service.Create(this.mapper.Map <Provider>(value)); return(this.mapper.Map <Provider>(provider)); }
public async Task <IActionResult> CreateProvider(NewProviderDTO newProvider) { try { if (newProvider.Name.Equals(newProvider.Location)) { ModelState.AddModelError("Location", "Provider location and name cannot be identical."); } if (await _providerService.ProviderExistsAsync(newProvider.Name)) { ModelState.AddModelError("Name", "A provider with the specified name already exists!"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ProviderDTO createdProvider = await _providerService.CreateAsync(newProvider); if (createdProvider == null) { return(Problem()); } return(CreatedAtRoute("GetProvider", new { id = createdProvider.Id }, createdProvider)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "An error occured.")); } }
public async Task <IActionResult> UpdateProvider(int id, ProviderDTO provider) { try { if (id != provider.Id) { ModelState.AddModelError("Identifier", "Specified id does not match request body."); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await _providerService.GetByIdAsync(id, false) == null) { return(NotFound()); } await _providerService.UpdateAsync(provider); return(NoContent()); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "An error occured.")); } }
public async Task Insert(ProviderDTO provider) { _context.Providers.Add(provider); await _context.SaveChangesAsync(); //kakaa }
public async Task Insert(ProviderDTO provider) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = _options.ConnectionString; SqlCommand command = new SqlCommand(); command.CommandText = "INSERT INTO PROVIDERS (FANTASYNAME,EMAIL,CNPJ,PHONE) VALUES (@FANTASYNAME,@EMAIL,@CNPJ,@PHONE); select scope_identity()"; command.Parameters.AddWithValue(@"FANTASYNAME", provider.FantasyName); command.Parameters.AddWithValue(@"EMAIL", provider.Email); command.Parameters.AddWithValue(@"CNPJ", provider.CNPJ); command.Parameters.AddWithValue(@"PHONE", provider.Phone); command.Connection = connection; Response response = new Response(); try { await connection.OpenAsync(); int idGerado = Convert.ToInt32(command.ExecuteScalar()); } catch (Exception ex) { response.Errors.Add("Erro no banco de dados, contate o administrador!"); File.WriteAllText("log.txt", ex.Message); } finally { await connection.CloseAsync(); } }
public async Task <bool> Post(ProviderDTO provider) { var model = _mapper.Map <ProviderModel>(provider); var entity = _mapper.Map <ProviderEntity>(model); return(await _repository.InsertAsync(entity)); }
public ActionResult Edit(int?id) { _logger.LogInformation($"{DateTime.Now.ToString()}: Processing request Provider/Edit"); try { ProviderDTO providerDto = _providerService.GetProvider(id); if (providerDto == null) { throw new ValidationException(_sharedLocalizer["ProviderNoFind"], ""); } var provider = new EditProviderViewModel() { Id = providerDto.Id, Email = providerDto.Email, Info = providerDto.Info, IsActive = providerDto.IsActive, IsFavorite = providerDto.IsFavorite, Name = providerDto.Name, Path = _path + providerDto.Path, TimeWorkTo = providerDto.TimeWorkTo, TimeWorkWith = providerDto.TimeWorkWith, WorkingDays = providerDto.WorkingDays }; return(View(provider)); } catch (ValidationException ex) { return(Content(ex.Message)); } }
public void Deactivate(ProviderDTO providerDTO) { providerDTO.Active = false; var provider = Map(providerDTO); db.Providers.Update(provider); db.Save(); }
public void SetActiveStatus(ProviderDTO providerDTO, bool isActive) { providerDTO.Active = isActive; var provider = Map(providerDTO); db.Providers.Update(provider); db.Save(); }
public async Task <ProviderDTOResult> Put(ProviderDTO provider) { var model = _mapper.Map <ProviderModel>(provider); var entity = _mapper.Map <ProviderEntity>(model); var result = await _repository.UpdateByCnpj(entity); return(_mapper.Map <ProviderDTOResult>(result)); }
protected void SetMetaTags(ProviderDTO providerseo) { keyword = (HtmlMeta)Master.FindControl("Keywords"); title = (HtmlTitle)Master.FindControl("Title"); keyword.Content = "Offshore outsourcing, Freelancers, India, Russia, Ukraine, php Programmers, Coders, Developers, Writers, Web Designers, Website Design, Technical Writers"; title.Text = "Register an Account - Work4Sale"; }
/// <summary> /// Actualiza un Provider por medio del id /// </summary> public void Update(string id, ProviderDTO entity) { using (var dbContextScope = new TiendaDbContext()) { _repository.Update(this.GetEntity(entity), id); dbContextScope.SaveChanges(); } }
public void Put(string id, [FromBody] ProviderDTO value) { var provider = this.service.Get(id); TryValidateModel(value); this.mapper.Map <ProviderDTO, Provider>(value, provider); this.service.Update(provider); }
public async Task <ActionResult> Edit(ProviderViewModel providerView) { ProviderDTO providerDTO = Mapper.Map <ProviderDTO>(providerView); await providerService.UpdateAsync(providerDTO); return(RedirectToAction("Index")); }