コード例 #1
0
        internal void Alter(int id)
        {
            User user = userBusiness.GetById(id);
            Dictionary <string, string> originalValues = GenerateDictionaries.generateUserDictionary(user.Id, user.Name, user.Email);

            Console.WriteLine("Se não hover necessidade de alteração de algum campo deixe-o vazio...");
            Console.WriteLine($"Nome atual:{user.Name}");
            Console.WriteLine("Novo nome:");
            var name = Console.ReadLine();

            Console.WriteLine($"Email atual:{user.Email}");
            Console.WriteLine("Novo email:");
            var email = Console.ReadLine();
            Dictionary <string, string> updatedValues = GenerateDictionaries.generateUserDictionary(user.Id,
                                                                                                    String.IsNullOrEmpty(name) ? user.Name : name,
                                                                                                    String.IsNullOrEmpty(email) ? user.Email : email);

            try
            {
                userBusiness.Update(originalValues, updatedValues);
                UsersList = userBusiness.Read();
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #2
0
        internal void Alter(int id)
        {
            TypePlan type = typeBusiness.GetById(id);
            Dictionary <string, string> originalValues = GenerateDictionaries.generateTypeDictionary(type.Id, type.Name, type.Description);

            Console.WriteLine("Se não hover necessidade de alteração de algum campo deixe-o vazio...");
            Console.WriteLine($"Nome atual:{type.Name}");
            Console.WriteLine("Novo nome:");
            var name = Console.ReadLine();

            Console.WriteLine($"Descrição:{type.Description}");
            Console.WriteLine("Nova descrição:");
            var description = Console.ReadLine();
            Dictionary <string, string> updatedValues = GenerateDictionaries.generateTypeDictionary(type.Id,
                                                                                                    String.IsNullOrEmpty(name) ? type.Name : name,
                                                                                                    String.IsNullOrEmpty(description) ? type.Description : description);

            try
            {
                typeBusiness.Update(originalValues, updatedValues);
                TypeList = typeBusiness.Read();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
        internal void Alter(int id)
        {
            Plan p = planBusiness.GetById(id);
            var  interestedPeople = p.Interested != null?string.Join(",", p.Interested.Select(plan => plan.Id)) : "";

            Dictionary <string, string> originalValues = GenerateDictionaries.generatePlanDictionary(p.Id, p.Name, p.Sponsor.Id,
                                                                                                     p.Type.Id, interestedPeople, p.Description, p.Cost, Convert.ToString(p.StartDate), Convert.ToString(p.EndDate));

            Console.WriteLine("Se não hover necessidade de mudança em algum campo deixe-o vazio...");
            Console.WriteLine("Informações atuais : ");
            Console.WriteLine(p.ToString());
            Console.WriteLine("Novo nome:");
            var name = Console.ReadLine();

            Console.WriteLine("Id do novo Responsavel:");
            var idSponsor = Console.ReadLine();

            Console.WriteLine("Id do novo Tipo:");
            var idType = Console.ReadLine();

            Console.WriteLine("Id das pessoas interessadas(separado por virgula):");
            var idInterested = Console.ReadLine();

            Console.WriteLine("Nova descrição:");
            var description = Console.ReadLine();

            Console.WriteLine("Custo(R$):");
            var cost = Console.ReadLine();

            Console.WriteLine("Data de inicio(ex: 04/04/2018):");
            var start = Console.ReadLine();

            Console.WriteLine("Data de termino(ex: 04/04/2018):");
            var end = Console.ReadLine();
            Dictionary <string, string> updatedValues = GenerateDictionaries.generatePlanDictionary(p.Id,
                                                                                                    String.IsNullOrEmpty(name) ? p.Name : name,
                                                                                                    String.IsNullOrEmpty(idSponsor) ? Convert.ToString(p.Sponsor.Id): idSponsor,
                                                                                                    String.IsNullOrEmpty(idType) ? Convert.ToString(p.Type.Id) :idType,
                                                                                                    String.IsNullOrEmpty(idInterested) ? string.Join(",", p.Interested.Select(plan => plan.Id)) : idInterested,
                                                                                                    String.IsNullOrEmpty(description) ? p.Description : description,
                                                                                                    String.IsNullOrEmpty(cost) ? Convert.ToString(p.Cost) : cost,
                                                                                                    String.IsNullOrEmpty(start) ? Convert.ToString(p.StartDate) : start,
                                                                                                    String.IsNullOrEmpty(end) ? Convert.ToString(p.EndDate) : end);

            try
            {
                planBusiness.Update(originalValues, updatedValues);
                PlanList = planBusiness.Read();
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }