Ejemplo n.º 1
0
        public ActionResult AddCarCompany(RentaCompany rentaHelp)
        {
            if (_context.RentaCompanies.Any(x => x.Id == rentaHelp.Id))
            {
                return(Content("Already exists!"));
            }
            else
            {
                var company = new RentaCompany
                {
                    Id       = rentaHelp.Id,
                    Name     = rentaHelp.Name,
                    Promo    = rentaHelp.Promo,
                    Adresa   = rentaHelp.Adresa,
                    Filijale = rentaHelp.Filijale,
                    ocena    = rentaHelp.ocena,
                    //ListaAuta = new List<Models.CarModels>()
                };

                _context.RentaCompanies.Add(company);
                _context.SaveChanges();
            }

            return(Ok());
        }
Ejemplo n.º 2
0
        public ActionResult <RentaHelp> GetCompany(string id)
        {
            RentaHelp    rentCompany = new RentaHelp();
            RentaCompany company     = _context.RentaCompanies.Where(x => x.Id == id).FirstOrDefault();

            rentCompany.ListaAuta = _context.CarsModels.Where(x => x.IDKompanije == company.Id).ToList();
            rentCompany.Name      = company.Name;
            rentCompany.ocena     = company.ocena;
            rentCompany.Promo     = company.Promo;
            rentCompany.Filijale  = company.Filijale;
            rentCompany.Adresa    = company.Adresa;
            return(rentCompany);
        }
Ejemplo n.º 3
0
        public void SaveCarCompanyGrade(RentaCompany company)
        {
            if (company != null)
            {
                var companyFromDB = this._context.RentaCompanies.FirstOrDefault(x => x.Id == company.Id);
                companyFromDB.ocena = company.ocena;

                this._context.SaveChanges();

                //Samo koriguj nacin na koji racunas prosecnu ocenu
                //double ocena = Double.Parse(car.Ocena);
                //ocena =
            }
        }
Ejemplo n.º 4
0
        public ActionResult <RentaCompany> EditProfile(string Id, RentaCompany company)
        {
            _context.RentaCompanies.Update(company);

            try
            {
                _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(CreatedAtAction("EditCarCompany", new { id = company.Id }, company));
        }