public string AddVehicleMake(VehicleMake vehicleMake)
        {
            string result = "";

            try
            {
                SqlCommand cmd = new SqlCommand();

                string Query = @"INSERT INTO VehicleMake (Name,Abrv)  
                                               Values(@Name,@Abrv)";

                cmd = new SqlCommand(Query, con);
                cmd.Parameters.AddWithValue("@Name", vehicleMake.Name);
                cmd.Parameters.AddWithValue("@Abrv", vehicleMake.Abrv);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                result = "Record Added Successfully !";
            }
            catch (FaultException fex)
            {
                throw new FaultException <string>("Error: " + fex);
            }

            return(result);
        }
Beispiel #2
0
        // delete
        public void DeleteVehicleMake(int id)
        {
            VehicleMake vehicleMake = db.VehicleMake.Find(id);

            db.VehicleMake.Remove(vehicleMake);
            db.SaveChanges();
        }
Beispiel #3
0
        public void DeleteMake(Guid id)
        {
            VehicleMake vehicleMake = db.VehiclMakes.Find(id);

            db.VehiclMakes.Remove(vehicleMake);
            db.SaveChanges();
        }
Beispiel #4
0
        public VehicleMake DeleteVehicleMake(int makeId)
        {
            VehicleMake make = context.VehicleMakers.Find(makeId);

            if (make != null)
            {
                context.Remove(make);
                context.SaveChanges();
            }
            return(make);
        }
        public VehicleMake GetVehicleMakeId(int?id)
        {
            var         vehicleMake  = from vma in _db.VehicleMakes where vma.Id == id select vma;
            VehicleMake vehicleMakes = new VehicleMake();

            foreach (var item in vehicleMake)
            {
                vehicleMakes.Id   = item.Id;
                vehicleMakes.Name = item.Name;
                vehicleMakes.Abrv = item.Abrv;
            }
            return(vehicleMakes);
        }
        public string DeleteVehicleMake(VehicleMake vehicleMake)
        {
            string     result = "";
            SqlCommand cmd    = new SqlCommand();
            string     Query  = "DELETE FROM VehicleMake Where Id=@Id";

            cmd = new SqlCommand(Query, con);
            cmd.Parameters.AddWithValue("@Id", vehicleMake.Id);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            result = "Record Deleted Successfully!";
            return(result);
        }
Beispiel #7
0
 public void SaveVehicleMake(VehicleMake vehicleMake)
 {
     if (vehicleMake.Id == 0)
     {
         context.Add(vehicleMake);
         context.SaveChanges();
     }
     else
     {
         var vehicle = context.VehicleMakers.Attach(vehicleMake);
         vehicle.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #8
0
        public bool RemoveMake(int?Id)
        {
            VehicleMake vm = this.db.VehicleMakes.Find(Id);

            var result = (from r in this.db.VehicleModels where r.VehicleMakeId == Id select r).FirstOrDefault();

            if (result == null)
            {
                this.db.VehicleMakes.Remove(vm);
                this.db.SaveChanges();
                return(true);
            }

            return(false);
        }
        public string UpdateVehicleMake(VehicleMake vehicleMake)
        {
            string     result = "";
            SqlCommand cmd    = new SqlCommand();

            string Query = "UPDATE VehicleMake SET Abrv=@Abrv,Name=@Name WHERE Id=@Id";

            cmd = new SqlCommand(Query, con);
            cmd.Parameters.AddWithValue("@Id", vehicleMake.Id);
            cmd.Parameters.AddWithValue("@Name", vehicleMake.Name);
            cmd.Parameters.AddWithValue("@Abrv", vehicleMake.Abrv);
            con.Open();
            cmd.ExecuteNonQuery();
            result = "Record Updated Successfully !";
            con.Close();

            return(result);
        }
Beispiel #10
0
        public async Task <VehicleMake> UpdateAsync(VehicleMake updatedItem)
        {
            var updatedItemEntity = await repository.UpdateAsync(mapper.Map <VehicleMakeEntity>(updatedItem));

            return(mapper.Map <VehicleMake>(updatedItemEntity));



            //var item = repository.repository.context.VehicleMakes.Update(mapper.Map<VehicleMakeEntity>(updatedItem));

            //item.State = EntityState.Modified;

            //await repository.repository.context.SaveChangesAsync();

            //return updatedItem;


            //var existingItem = await repository.GetAsync((mapper.Map<VehicleMakeEntity>(updatedItem)).Id);

            //repository.repository.context.Update(existingItem);
            //repository.repository.context.SaveChanges();

            //return mapper.Map<VehicleMake>(existingItem);
        }
Beispiel #11
0
 // create
 public void CreateVehicleMake(VehicleMake vehicleMake)
 {
     db.VehicleMake.Add(Mapper.Map <VehicleMake>(vehicleMake));
     db.SaveChanges();
 }
 public bool AddMaker(VehicleMake maker)
 {
     context.Makers.Add(maker);
     return(Convert.ToBoolean(context.SaveChanges()));
 }
Beispiel #13
0
 public async Task UpdateAsync(VehicleMake vehicleMake)
 {
     await _repository.UpdateAsync(vehicleMake);
 }
Beispiel #14
0
 public async Task InsertAsync(VehicleMake vehicleMake)
 {
     await _repository.InsertAsync(vehicleMake);
 }
Beispiel #15
0
 public void Detach(VehicleMake item)
 {
     throw new NotImplementedException();
 }
Beispiel #16
0
        public async Task <VehicleMake> CreteAsync(VehicleMake newItem)
        {
            var newItemEntity = await repository.CreteAsync(mapper.Map <VehicleMakeEntity>(newItem));

            return(mapper.Map <VehicleMake>(newItemEntity));
        }
Beispiel #17
0
 public void InsertVehicleMake(VehicleMake make)
 {
     _context.VehicleMakes.Add(make);
     _context.SaveChanges();
 }
 public async Task <int> CreateAsync(VehicleMake vehicleMake)
 {
     return(await VehicleMakeRepository.InsertAsync(vehicleMake));
 }
 public async Task <int> UpdateAsync(VehicleMake vehicleMake)
 {
     return(await VehicleMakeRepository.UpdateAsync(vehicleMake));
 }
Beispiel #20
0
        public VehicleMakeVM FindVehicleMake(Guid id)
        {
            VehicleMake vehicleMake = db.VehiclMakes.Find(id);

            return(Mapper.Map <VehicleMakeVM>(vehicleMake));//mapping iz source(vehicleMake model) u VehicleMakeViewModel
        }
Beispiel #21
0
 // update
 public void UpdateVehicleMake(VehicleMake vehicleMake)
 {
     db.Set <VehicleMake>().AddOrUpdate(Mapper.Map <VehicleMake>(vehicleMake));
     db.SaveChanges();
 }
Beispiel #22
0
 public void Add(VehicleMake vehicleMake)
 {
     this.db.VehicleMakes.Add(vehicleMake);
     this.db.SaveChanges();
 }
Beispiel #23
0
 public void UpdateVehicleMake(VehicleMake make)
 {
     throw new NotImplementedException();
 }
Beispiel #24
0
 public void Edit(VehicleMake vehicleMake)
 {
     this.db.Entry(vehicleMake).State = EntityState.Modified;
     this.db.SaveChanges();
 }