Пример #1
0
        public static Service AddNew(int Id, string serviceName, float unitPrice, float netPrice, int Vat)
        {
            try
            {
                using (var context = new ServicesDBEntities())
                {
                    var newservice = new Service
                    {
                        ServiceName = serviceName,
                        UnitPrice = unitPrice,
                        NetPrice = netPrice,
                        Vat = Vat,
                        VatAmount = ((Vat * unitPrice) / 100),
                        PretaxPrice = (unitPrice + (Vat * unitPrice) / 100),
                    };
                    context.Services.Add(newservice);
                    context.SaveChanges();

                    return newservice;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Пример #2
0
        public static Customer AddNew(string name, string surname, string companyName, string street, string city, int code, int? phoneNumber, int NIP)
        {
            try
            {
                using (var context = new ServicesDBEntities())
                {
                    var newPerson = new Customer
                    {
                        Name = name,
                        Surname = surname,
                        CompanyName = companyName,
                        Street = street,
                        City = city,
                        Code = code,
                        PhoneNumber = phoneNumber,
                        NIP = NIP
                    };
                    context.Customers.Add(newPerson);
                    context.SaveChanges();

                    return newPerson;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Пример #3
0
        public static Customer Delete(int projectId)
        {
            try
            {
                using (var context = new ServicesDBEntities())
                {
                    var deleteServive = (context.Services
                    .Where(p => p.Id == projectId)
                    .FirstOrDefault());
                    context.Services.Remove(deleteServive);
                    context.SaveChanges();

                    return null;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Пример #4
0
        public static Service Edit(int Id, string serviceName, float unitPrice, float netPrice, int VAT)
        {
            try
            {
                using (var context = new ServicesDBEntities())
                {
                    var editService = (context.Services
                        .Where(p => p.Id == Id)
                        .FirstOrDefault());
                    editService.ServiceName = serviceName;
                    editService.UnitPrice = unitPrice;
                    editService.NetPrice = netPrice;
                    editService.Vat = VAT;

                    context.SaveChanges();
                    return editService;
                };
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Пример #5
0
        public static Customer Edit(int Id, string name, string surname, string companyName, string street, string city, int code, int? phoneNumber, int NIP)
        {
            try
            {
                using (var context = new ServicesDBEntities())
                {
                    var editPerson = (context.Customers
                        .Where(p => p.Id == Id)
                        .FirstOrDefault());

                    editPerson.Name = name;
                    editPerson.Surname = surname;
                    editPerson.CompanyName = companyName;
                    editPerson.Street = street;
                    editPerson.City = city;
                    editPerson.Code = code;
                    editPerson.PhoneNumber = phoneNumber;
                    editPerson.NIP = NIP;

                    context.SaveChanges();
                    return editPerson;
                };
            }
            catch (Exception ex)
            {
                return null;
            }
        }