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);
        }
Example #2
0
        // delete
        public void DeleteVehicleMake(int id)
        {
            VehicleMake vehicleMake = db.VehicleMake.Find(id);

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

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

            return(mapper.Map <VehicleMake>(newItemEntity));
        }
Example #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));
 }
Example #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
        }
Example #21
0
 // update
 public void UpdateVehicleMake(VehicleMake vehicleMake)
 {
     db.Set <VehicleMake>().AddOrUpdate(Mapper.Map <VehicleMake>(vehicleMake));
     db.SaveChanges();
 }
Example #22
0
 public void Add(VehicleMake vehicleMake)
 {
     this.db.VehicleMakes.Add(vehicleMake);
     this.db.SaveChanges();
 }
Example #23
0
 public void UpdateVehicleMake(VehicleMake make)
 {
     throw new NotImplementedException();
 }
Example #24
0
 public void Edit(VehicleMake vehicleMake)
 {
     this.db.Entry(vehicleMake).State = EntityState.Modified;
     this.db.SaveChanges();
 }