Beispiel #1
0
        internal static bool UpdateOwner(CompanyOwner oldOwner)
        {
            DatabaseEntities entities = new DatabaseEntities();
            Owner            dbOwner  = entities.Owners.FirstOrDefault(p => p.OwnerId == oldOwner.OwnerId);

            if (dbOwner == null)
            {
                return(false);
            }
            dbOwner.CompanyName = oldOwner.CompanyName;
            dbOwner.Address     = oldOwner.Address;
            dbOwner.Email       = oldOwner.Email;
            dbOwner.Phone       = oldOwner.Phone;
            dbOwner.VATNumber   = oldOwner.VatNumber;
            dbOwner.Bulstat     = oldOwner.Bulstat;
            dbOwner.Bank        = oldOwner.Bank;
            dbOwner.IBAN        = oldOwner.Iban;
            dbOwner.SWIFTCode   = oldOwner.SwiftCode;

            entities.Owners.Attach(dbOwner);
            var entry = entities.Entry(dbOwner);

            entry.Property(e => e.CompanyName).IsModified = true;
            entry.Property(e => e.Address).IsModified     = true;
            entry.Property(e => e.Email).IsModified       = true;
            entry.Property(e => e.Phone).IsModified       = true;
            entry.Property(e => e.VATNumber).IsModified   = true;
            entry.Property(e => e.Bulstat).IsModified     = true;
            entry.Property(e => e.Bank).IsModified        = true;
            entry.Property(e => e.IBAN).IsModified        = true;
            entry.Property(e => e.SWIFTCode).IsModified   = true;
            entities.SaveChanges();
            return(true);
        }
Beispiel #2
0
        public Person EditPerson(int id, string surname, string firstname, string middlename, string phone, string email,
                                 string country, string city, string street, string building, string index,
                                 string login, string password, bool isWorking, string description,
                                 string inn, string ogrn)
        {
            CompanyOwner p = (CompanyOwner)cont.Person.SingleOrDefault(ca => ca.Id == id);

            p.Surname    = surname;
            p.FirstName  = firstname;
            p.MiddleName = middlename;
            p.Phone      = phone;
            p.Email      = email;

            p.Adress = new Adress
            {
                Country = country,
                City    = city,
                Street  = street,
                Bilding = building,
                Index   = index
            };

            p.Login       = login;
            p.Password    = password;
            p.IsWorking   = isWorking;
            p.Description = description;

            p.INN  = inn;
            p.OGRN = ogrn;

            cont.SaveChanges();
            return(p);
        }
Beispiel #3
0
        public static async Task <bool> PostUpdateOwner(CompanyOwner owner)
        {
            HttpResponseMessage response;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(DataHolder.ServerAddress);
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic");

                try
                {
                    response = await client.PostAsJsonAsync("api/owner/update", owner);
                }
                catch (HttpRequestException ex)
                {
                    throw new Exception(ex.InnerException.Message);
                }

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                return(await response.Content.ReadAsAsync <bool>());
            }
        }
Beispiel #4
0
        public CompanyOwner AddCompanyOwner(string surname, string firstname, string middlename, string phone, string email,
                                            Adress adress,
                                            string login, string password, string description,
                                            string inn, string ogrn, Position position)
        {
            CompanyOwner p = new CompanyOwner
            {
                Surname    = surname,
                FirstName  = firstname,
                MiddleName = middlename,
                Phone      = phone,
                Email      = email,

                Adress = adress,

                Login       = login,
                Password    = password,
                IsWorking   = true,
                Description = description,

                Branch = null,

                INN      = inn,
                OGRN     = ogrn,
                Position = position,
            };

            cont.Person.Add(p);
            cont.SaveChanges();
            return(p);
        }
Beispiel #5
0
        public static async Task <CompanyOwner> getOwner(Guid ownerId)
        {
            CompanyOwner        owner = new CompanyOwner();
            HttpResponseMessage response;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(DataHolder.ServerAddress);
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic");

                try
                {
                    response = await client.GetAsync("api/owner/" + ownerId);
                }
                catch (HttpRequestException ex)
                {
                    throw new Exception(ex.InnerException.Message);
                }

                if (response.IsSuccessStatusCode)
                {
                    owner = await response.Content.ReadAsAsync <CompanyOwner>();
                }
            }
            return(owner);
        }
        public Branch AddBranch(string website, string phone, DateTime startWorkingTime, DateTime endtWorkingTime,
                                string country, string city, string street, string building, string index,
                                CompanyOwner owner, Landlord landlord)
        {
            Branch b = new Branch
            {
                WebSite          = website,
                Phone            = phone,
                StartWorkingTime = new TimeSpan(startWorkingTime.Hour, startWorkingTime.Minute, startWorkingTime.Second),
                EndWorkingTime   = new TimeSpan(endtWorkingTime.Hour, endtWorkingTime.Minute, endtWorkingTime.Second),

                Adress =
                {
                    Country = country,
                    City    = city,
                    Street  = street,
                    Bilding = building,
                    Index   = index
                },

                Owner    = owner,
                Landlord = landlord,
            };

            cont.Branch.Add(b);
            cont.SaveChanges();
            return(b);
        }
        public Branch EditBranch(int id, string website, string phone, DateTime startWorkingTime, DateTime endtWorkingTime,
                                 string country, string city, string street, string building, string index,
                                 CompanyOwner owner, Landlord landlord)
        {
            Branch b = cont.Branch.SingleOrDefault(ca => ca.Id == id);

            b.WebSite          = website;
            b.Phone            = phone;
            b.StartWorkingTime = new TimeSpan(startWorkingTime.Hour, startWorkingTime.Minute, startWorkingTime.Second);
            b.EndWorkingTime   = new TimeSpan(endtWorkingTime.Hour, endtWorkingTime.Minute, endtWorkingTime.Second);

            b.Adress = new Adress
            {
                Country = country,
                City    = city,
                Street  = street,
                Bilding = building,
                Index   = index
            };

            b.Owner    = owner;
            b.Landlord = landlord;

            cont.SaveChanges();
            return(b);
        }
Beispiel #8
0
        public CompanyOwner EditCompanyOwner(int id, string surname, string firstname, string middlename, string phone, string email,
                                             string login, string password, bool isWorking, string description,
                                             string inn, string ogrn)
        {
            CompanyOwner p = (CompanyOwner)cont.Person.SingleOrDefault(ca => ca.Id == id);

            p.Surname    = surname;
            p.FirstName  = firstname;
            p.MiddleName = middlename;
            p.Phone      = phone;
            p.Email      = email;

            p.Adress = null;

            p.Login       = login;
            p.Password    = password;
            p.IsWorking   = isWorking;
            p.Description = description;

            p.INN  = inn;
            p.OGRN = ogrn;

            cont.SaveChanges();
            return(p);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ContactEmail")] CompanyOwner companyOwner)
        {
            if (id != companyOwner.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companyOwner);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyOwnerExists(companyOwner.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyOwner));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,ContactEmail")] CompanyOwner companyOwner)
        {
            if (ModelState.IsValid)
            {
                _context.Add(companyOwner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(companyOwner));
        }
Beispiel #11
0
        private void FirstStart()
        {
            ModelContainer         cont                   = new ModelContainer();
            BranchRepository       branchRepository       = new BranchRepository(cont);
            CategoryRepository     categoryRepository     = new CategoryRepository(cont);
            CompanyOwnerRepository companyOwnerRepository = new CompanyOwnerRepository(cont);
            PersonRepository       personRepository       = new PersonRepository(cont);
            PositionRepository     positionRepository     = new PositionRepository(cont);
            RoomRepository         roomRepository         = new RoomRepository(cont);
            TableRepository        tableRepository        = new TableRepository(cont);
            ClientRepository       clientRepository       = new ClientRepository(cont);

            if (positionRepository.Positions().Count() == 0)
            {
                positionRepository.AddPosition("Суперпользователь", true, true, true, true, true, true);
            }

            CompanyOwner co = new CompanyOwner();

            if (personRepository.Persones().Count() == 0)
            {
                co = companyOwnerRepository.AddCompanyOwner("Суперпользователь", "", "", "", "", "super", "super".GetHashCode().ToString(), "", "", "",
                                                            positionRepository.GetPositionByName("Суперпользователь"));
            }

            Branch b = new Branch();

            if (branchRepository.Branches().Count() == 0)
            {
                b = branchRepository.AddBranch("", "", DateTime.Now, DateTime.Now, "", "", "", "", "", co, null);
            }

            Room r = new Room();

            if (roomRepository.Rooms().Count() == 0)
            {
                r = roomRepository.AddRoom("", b);
            }

            if (categoryRepository.Categotyes().Count() == 0)
            {
                categoryRepository.AddCategory("");
            }

            if (tableRepository.Tables().Count() == 0)
            {
                tableRepository.AddTable(1, "", r);
            }

            if (clientRepository.Clients().Count() == 0)
            {
                clientRepository.AddClient("Клиент", "", "", "", "", "", "", "", "", "", "", "");
            }
        }
 public EditCompanyForm()
 {
     InitializeComponent();
     Owner2             = new CompanyOwner();
     tbBulstat.Text     = !string.IsNullOrEmpty(DataHolder.Owner.Bulstat) ? DataHolder.Owner.Bulstat : "";
     tbVatNumber.Text   = !string.IsNullOrEmpty(DataHolder.Owner.VatNumber) ? DataHolder.Owner.VatNumber : "";
     tbAddress.Text     = !string.IsNullOrEmpty(DataHolder.Owner.Address) ? DataHolder.Owner.Address : "";;
     tbCompanyName.Text = !string.IsNullOrEmpty(DataHolder.Owner.CompanyName) ? DataHolder.Owner.CompanyName : "";
     tbEmail.Text       = !string.IsNullOrEmpty(DataHolder.Owner.Email) ? DataHolder.Owner.Email : "";
     tbPhone.Text       = !string.IsNullOrEmpty(DataHolder.Owner.Phone) ? DataHolder.Owner.Phone : "";
     tbBank.Text        = !string.IsNullOrEmpty(DataHolder.Owner.Bank) ? DataHolder.Owner.Bank : "";
     tbIban.Text        = !string.IsNullOrEmpty(DataHolder.Owner.Iban) ? DataHolder.Owner.Iban : "";
     tbSwift.Text       = !string.IsNullOrEmpty(DataHolder.Owner.SwiftCode) ? DataHolder.Owner.SwiftCode : "";
 }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CompanyOwner = await _context.CompanyOwner.FirstOrDefaultAsync(m => m.Id == id);

            if (CompanyOwner == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CompanyOwner = await _context.CompanyOwner.FindAsync(id);

            if (CompanyOwner != null)
            {
                _context.CompanyOwner.Remove(CompanyOwner);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public Branch EditBranch(int id, string website, string phone, DateTime startWorkingTime, DateTime endtWorkingTime,
                                 Adress adress,
                                 CompanyOwner owner, Landlord landlord)
        {
            Branch b = cont.Branch.SingleOrDefault(ca => ca.Id == id);

            b.WebSite          = website;
            b.Phone            = phone;
            b.StartWorkingTime = new TimeSpan(startWorkingTime.Hour, startWorkingTime.Minute, startWorkingTime.Second);
            b.EndWorkingTime   = new TimeSpan(endtWorkingTime.Hour, endtWorkingTime.Minute, endtWorkingTime.Second);

            b.Adress = adress;

            b.Owner    = owner;
            b.Landlord = landlord;

            cont.SaveChanges();
            return(b);
        }
Beispiel #16
0
        internal static CompanyOwner GetOwnerById(Guid ownerId)
        {
            CompanyOwner     owner    = new CompanyOwner();
            DatabaseEntities entities = new DatabaseEntities();
            Owner            dbOwner  = entities.Owners.FirstOrDefault(p => p.OwnerId == ownerId);

            if (dbOwner != null)
            {
                owner.OwnerId     = dbOwner.OwnerId;
                owner.Address     = dbOwner.Address;
                owner.CompanyName = dbOwner.CompanyName;
                owner.Email       = dbOwner.Email;
                owner.Phone       = dbOwner.Phone;
                owner.Bulstat     = dbOwner.Bulstat;
                owner.VatNumber   = dbOwner.VATNumber;
                owner.Bank        = dbOwner.Bank;
                owner.Iban        = dbOwner.IBAN;
                owner.SwiftCode   = dbOwner.SWIFTCode;
            }
            return(owner);
        }
        public Branch AddBranch(string website, string phone, DateTime startWorkingTime, DateTime endtWorkingTime,
                                Adress adress,
                                CompanyOwner owner, Landlord landlord)
        {
            Branch b = new Branch
            {
                WebSite          = website,
                Phone            = phone,
                StartWorkingTime = new TimeSpan(startWorkingTime.Hour, startWorkingTime.Minute, startWorkingTime.Second),
                EndWorkingTime   = new TimeSpan(endtWorkingTime.Hour, endtWorkingTime.Minute, endtWorkingTime.Second),

                Adress = adress,

                Owner    = owner,
                Landlord = landlord,
            };

            cont.Branch.Add(b);
            cont.SaveChanges();
            return(b);
        }
Beispiel #18
0
        public CompanyOwner AddCompanyOwner(string surname, string firstname, string middlename, string phone, string email,
                                            string country, string city, string street, string building, string index,
                                            string login, string password, string description,
                                            string inn, string ogrn, Position position)
        {
            CompanyOwner p = new CompanyOwner
            {
                Surname    = surname,
                FirstName  = firstname,
                MiddleName = middlename,
                Phone      = phone,
                Email      = email,

                Adress =
                {
                    Country = country,
                    City    = city,
                    Street  = street,
                    Bilding = building,
                    Index   = index
                },

                Login       = login,
                Password    = password,
                IsWorking   = true,
                Description = description,

                Branch = null,

                INN      = inn,
                OGRN     = ogrn,
                Position = position,
            };

            cont.Person.Add(p);
            cont.SaveChanges();
            return(p);
        }
 public Branch GetBranchByOwner(CompanyOwner companyOwner)
 {
     return(cont.Branch.SingleOrDefault(b => b.Owner == companyOwner));
 }
 public bool PostUpdateOwner([FromBody] CompanyOwner owner)
 {
     return(BLOwner.UpdateOwner(owner));
 }