/// <summary> /// Updates the cost associated with a given order /// </summary> /// <param name="idEncomenda">Unique identifier for a single order</param> /// <param name="custoInput">Cost of the order</param> public void UpdateCustoEnc(int idEncomenda, float custoInput) { Encomenda enc = _context.Encomendas.Find(idEncomenda); enc.custo += custoInput; _context.SaveChanges(); }
/// <summary> /// Updates the username associated with the given user ID /// </summary> /// <param name="idUser">Unique identifier of the user</param> /// <param name="nomeInput">New username</param> public void UpdateNome(int idUser, string nomeInput) { Utilizador user = _context.Utilizadores.Find(idUser); user.Nome = nomeInput; _context.SaveChanges(); }
/// <summary> /// Registers a service rating referring to a given order /// </summary> /// <param name="idEncomenda">Unique identifier for a single order</param> /// <param name="classServicoEntrega">Rating relating to the employee</param> /// <param name="classEstadoEncomenda">Rating relating to the order</param> public void avalia(int idEncomenda, int classServicoEntrega, int classEstadoEncomenda) { Encomenda enc = _eController.getEncomenda(idEncomenda); int idFun = enc.getFuncionarioID(); Funcionario funcionario = _fController.getFuncionario(idFun); enc.setAvaliacao(classEstadoEncomenda); funcionario.AtualizaAvaliacao(classServicoEntrega); _context.SaveChanges(); }
/// <summary> /// Checks input and if all is right, save the Cliente to the DataBase /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <param name="email"></param> /// <param name="morada"></param> /// <param name="telefone"></param> /// <returns>returns the correspondent Action</returns> public ActionResult Registar(string user, string password, string email, string morada, string telefone) { if (_uController.emailAssociado(email)) { return(EmailEmUso()); } if (this.telefoneValido(telefone) == false) { return(TelefoneInvalido()); } if (this.passwordSegura(password) == false) { return(PasswordInsegura()); } Cliente nCliente = _context.newCliente(user, UtilizadorController.hashFunction(password), email, morada, telefone); _context.Clientes.Add(nCliente); _context.SaveChanges(); return(Sucesso()); }