public IActionResult Update(int id, [FromBody] Rezervation value)
 {
     return(Ok(new List <Rezervation>()
     {
         service.Update(value)
     }));
 }
Example #2
0
        public RezDto CreateReservation(RezDto dto)
        {
          
            var rez = new Rezervation();
           
            rez.Create = dto.Create;
            rez.PeopleSum = dto.PeopleSum;
            rez.Note = dto.Note;
            
            rez.ApplicationUserId = dto.UserId;
            
            
            
            try
            {
                _context.Rezervations.Add(rez);
                _context.SaveChanges();
            }
            catch
            {
                return null;
            }
            

            return dto;

        }
Example #3
0
        public IActionResult Edit(Rezervation rezervation)
        {
            context.Rezervations.Update(rezervation);
            context.SaveChanges();

            return(RedirectToAction("List"));
        }
 public IActionResult Create([FromBody] Rezervation value)
 {
     return(Ok(new List <Rezervation>()
     {
         service.Create(value)
     }));
 }
Example #5
0
        public static RezervationModel ToModel(this Rezervation dbRezervation, ClientAccountModel clientAccountModel)
        {
            var model = dbRezervation.ToModel();

            model.ClientAccount = clientAccountModel;

            return(model);
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Rezervation rezervation = db.Rezervations.Find(id);

            db.Rezervations.Remove(rezervation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
 public ActionResult Edit([Bind(Include = "RezervationId,RoomName,CheckInDate,CheckOutDate,AdultNumber,ChildrenNumber")] Rezervation rezervation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rezervation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rezervation));
 }
Example #8
0
        public ActionResult Create([Bind(Include = "RezervationId,RoomName,CheckInDate,CheckOutDate,AdultNumber,ChildrenNumber")] Rezervation rezervation)
        {
            if (ModelState.IsValid)
            {
                db.Rezervations.Add(rezervation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rezervation));
        }
        public Rezervation Delete(int id)
        {
            var entity = new Rezervation()
            {
                Id = id
            };

            context.Set <Rezervation>().Attach(entity);
            context.Entry(entity).State = EntityState.Deleted;
            context.SaveChanges();
            return(entity);
        }
        public ActionResult Delete(int id)
        {
            Rezervation rezervation = ctx.Rezervations.Find(id);
            Persone     contact     = ctx.Persones.Find(rezervation.Persone.PersoneId);

            if (rezervation != null)
            {
                ctx.Rezervations.Remove(rezervation);
                ctx.Persones.Remove(contact);
                ctx.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(HttpNotFound("Couldn't find the rezervation with id " + id.ToString() + "!"));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     if (Convert.ToString(Session["Name"]) == "baran" && Convert.ToString(Session["Password"]) == "123456")
     {
         Rezervation rezervation = db.Rezervation.Find(id);
         db.Rezervation.Remove(rezervation);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
 public ActionResult Details(int?id)
 {
     if (id.HasValue)
     {
         Rezervation rezervation = ctx.Rezervations.Find(id);
         if (rezervation != null)
         {
             ViewBag.Region = ctx.Regions.Find(rezervation.Persone.RegionId).Name;
             return(View(rezervation));
         }
         return(HttpNotFound("Couldn't find the rezervation with id " + id.ToString() + "!"));
     }
     return(HttpNotFound("Missing rezervation id parameter!"));
 }
Example #13
0
        public async Task <IActionResult> makeARezervation(MakeARezervation makeARezervation)
        {
            try
            {
                var   guideId = makeARezervation.GuideId;
                Guide guide   = guideDbContext.Guides.Where(p => p.guideID == guideId).FirstOrDefault();
                if (makeARezervation.PersonAge > guide.AgeLimit)
                {
                    return(BadRequest("Your age is above limit"));
                }

                foreach (var user in makeARezervation.users)
                {
                    Rezervation rez = new Rezervation();

                    int bday = user.Birthday.Year;
                    int age  = DateTime.Now.Year - bday;
                    if (age > guide.AgeLimit)
                    {
                        return(BadRequest("Age is above limit for your friend " + user.Firstname + user.Lastname));
                    }
                    else
                    {
                        rez.Firstname       = user.Firstname;
                        rez.Lastname        = user.Lastname;
                        rez.RezervationDate = DateTime.Now;
                        rez.UpdatedDate     = DateTime.Now;
                        rez.GuideId         = guideId;
                        rez.PersonAge       = age;
                        guideRepository.Add(rez);
                        var save = await guideRepository.SaveAsync(rez);
                    }
                }
                Rezervation rez1 = new Rezervation();
                rez1.GuideId         = makeARezervation.GuideId;
                rez1.Firstname       = makeARezervation.Firstname;
                rez1.Lastname        = makeARezervation.Lastname;
                rez1.PersonAge       = makeARezervation.PersonAge;
                rez1.RezervationDate = DateTime.Now;
                rez1.UpdatedDate     = DateTime.Now;
                guideRepository.Add(rez1);
                var save1 = await guideRepository.SaveAsync(rez1);

                return(StatusCode(201));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #14
0
        // GET: Rezervations/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rezervation rezervation = db.Rezervations.Find(id);

            if (rezervation == null)
            {
                return(HttpNotFound());
            }
            return(View(rezervation));
        }
        public ActionResult Edit(int?id)
        {
            if (id.HasValue)
            {
                Rezervation furniture = ctx.Rezervations.Find(id);

                if (furniture == null)
                {
                    return(HttpNotFound("Couldn't find the rezervation type with id " + id.ToString() + "!"));
                }
                return(View(furniture));
                //return RedirectToAction("Index");
            }
            return(HttpNotFound("Couldn't find the rezervation type with id " + id.ToString() + "!"));
        }
Example #16
0
 public static RezervationModel ToModel(this Rezervation dbRezervation)
 {
     return(new RezervationModel
     {
         CancelationFeeRate = dbRezervation.CancelationFeeRate,
         CancellationFee = dbRezervation.CancellationFee,
         CarPlateNumber = dbRezervation.CarPlateNumber,
         CarType = (CarTypeEnum)dbRezervation.CarType,
         DepositFee = dbRezervation.DepositFee,
         IsCancelled = dbRezervation.IsCancelled,
         IsPickedUp = dbRezervation.IsPickedUp,
         IsReturned = dbRezervation.IsReturned,
         PickUpDate = dbRezervation.PickUpDate,
         RentaltFee = dbRezervation.RentaltFee,
         ReturnDate = dbRezervation.ReturnDate,
         RezervationId = dbRezervation.RezervationId,
     });
 }
 public ActionResult Edit([Bind(Include = "id,UsersId,FieldsId,Date,HoursId,IsComplated")] Rezervation rezervation)
 {
     if (Convert.ToString(Session["Name"]) == "baran" && Convert.ToString(Session["Password"]) == "123456")
     {
         if (ModelState.IsValid)
         {
             db.Entry(rezervation).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.FieldsId = new SelectList(db.Fields, "id", "id", rezervation.FieldsId);
         ViewBag.HoursId  = new SelectList(db.Hours, "id", "Hour", rezervation.HoursId);
         ViewBag.UsersId  = new SelectList(db.Users, "id", "Name", rezervation.UsersId);
         return(View(rezervation));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
 // GET: RezervationsAdmin/Details/5
 public ActionResult Details(int?id)
 {
     if (Convert.ToString(Session["Name"]) == "baran" && Convert.ToString(Session["Password"]) == "123456")
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Rezervation rezervation = db.Rezervation.Find(id);
         if (rezervation == null)
         {
             return(HttpNotFound());
         }
         return(View(rezervation));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Example #19
0
        public async Task <bool> Handle(CreateReservationRequest request, CancellationToken cancellationToken)
        {
            int roomId = int.Parse(request.RoomId);
            var room   = await _context.Rooms.FirstOrDefaultAsync(x => x.Id == roomId, cancellationToken);

            if (room == null)
            {
                throw new ValidationException($"room not found {request.RoomId}");
            }

            if (!request.Members.Any())
            {
                throw new BussinesException("must have at least 1 guest in the meeting");
            }

            //gerekli kontrollerin yapıldığını hesaplıyorum. Daha önceden rezerasyon varmı yok mu vs.
            //Rezerve tarihi bitiş başlangıctan kücük olamaz
            var reservation = new Rezervation
            {
                OwnerEmail       = request.OwnerEmail,
                OwnerName        = request.OwnerName,
                RezervationStart = Convert.ToDateTime(request.ReservationStart, new CultureInfo("tr")),
                RezervationEnd   = Convert.ToDateTime(request.ReservationEnd, new CultureInfo("tr")),
                Room             = room
            };

            foreach (var item in request.Members)
            {
                reservation.Members.Add(new Member()
                {
                    Email = item.Email,
                    State = State.Waiting
                });
            }

            await _context.AddAsync(reservation, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(true);
        }
 public ActionResult DeleteConfirmed(int id)
 {
     if (Convert.ToString(Session["Name"]) == "baran" && Convert.ToString(Session["Password"]) == "123456")
     {
         Rezervation rezervation       = new Rezervation();
         var         removerezervation = db.Rezervation.Where(x => x.UsersId == id).ToList();
         foreach (var item in removerezervation)   //Kullanıcıların silinmesi için yaptırdığı rezervasyonlarında silinmesi gerekiyor.
         {                                         //Bu yüzden rezervasyonlarıda sildim.
             db.Rezervation.Remove(item);
             db.SaveChanges();
         }
         Users users = db.Users.Find(id);
         db.Users.Remove(users);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        public IActionResult Index()
        {
            Rezervation rv = new Rezervation();
            Guest       ge = new Guest();
            Payment     py = new Payment();

            //rv.Id = 1;
            //rv.DepartureDate = DateTime.Today.Date;
            //rv.Arrivaldate = DateTime.Today.Date.AddDays(1);
            //rv.RoomNo = "102";
            //rv.TatolDays = 1;
            //ge.Name = "Ömer";
            //ge.SurName = "Çetin";


            var model = context.Rezervations
                        .Include(i => i.Guests)
                        .Include(i => i.Payments)
                        .ToList();

            return(View(model));
        }
        public ActionResult Edit(int id, Rezervation pcViewModel)
        {
            //pcViewModel.Region= GetAllRegions();
            //roomRequest.RezervationList = GetAllGenderTypes();
            ViewBag.RegionList = GetAllRegions();
            ViewBag.GenderList = GetAllGenderTypes();


            // preluam cartea pe care vrem sa o modificam din baza de date
            Rezervation room = ctx.Rezervations
                               .SingleOrDefault(b => b.RezervationId.Equals(id));

            // memoram intr-o lista doar genurile care au fost selectate din formular

            try
            {
                if (ModelState.IsValid)
                {
                    if (TryUpdateModel(room))
                    {
                        room.Persone = pcViewModel.Persone;

                        // vom adauga in baza de date ambele obiecte
                        //ctx.Persones.Add(persone);

                        room.Name = pcViewModel.Name;
                        //ctx.Rezervations.Add(rezervation);
                        ctx.SaveChanges();
                    }
                    return(RedirectToAction("Index"));
                }
                return(View(pcViewModel));
            }
            catch (Exception)
            {
                return(View(pcViewModel));
            }
        }
 // GET: RezervationsAdmin/Edit/5
 public ActionResult Edit(int?id)
 {
     if (Convert.ToString(Session["Name"]) == "baran" && Convert.ToString(Session["Password"]) == "123456")
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Rezervation rezervation = db.Rezervation.Find(id);
         if (rezervation == null)
         {
             return(HttpNotFound());
         }
         ViewBag.FieldsId = new SelectList(db.Fields, "id", "id", rezervation.FieldsId);
         ViewBag.HoursId  = new SelectList(db.Hours, "id", "Hour", rezervation.HoursId);
         ViewBag.UsersId  = new SelectList(db.Users, "id", "Name", rezervation.UsersId);
         return(View(rezervation));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Example #24
0
        public IActionResult Create([Bind(Prefix = "Item1")] Rezervation Model1, [Bind(Prefix = "Item2")] Guest Model2, [Bind(Prefix = "Item3")] Payment Model3)
        {
            //var all = from b in context.Rezervations
            //          join g in context.Guests
            //          on b.Id equals g.RezervationId
            //          join p in context.Payments
            //          on b.Id equals p.RezervationId
            //          select new
            //          {
            //              b.Arrivaldate,
            //              b.DepartureDate,
            //              g.Name,
            //              g.SurName,
            //              p.TotalPrice
            //          };

            //Rez.DepartureDate = Model1.DepartureDate;
            //gue.Name = Model2.Name;
            //gue.SurName = Model2.SurName;
            //pay.TotalPrice = Model3.TotalPrice;

            //Rez.InsertDateTime = DateTime.Now;
            //gue.InsertDateTime = DateTime.Now;
            //gue.GuestSequenceNo = 1;
            //pay.InsertDateTime = DateTime.Now;



            context.Rezervations.Add(Model1);
            context.Guests.Add(Model2);
            context.Payments.Add(Model3);

            context.SaveChanges();


            return(RedirectToAction("List"));
        }
        public ActionResult New(RezervationContactViewModel pcViewModel)
        {
            ViewBag.RegionList = GetAllRegions();
            ViewBag.GenderList = GetAllGenderTypes();

            try
            {
                if (ModelState.IsValid)
                {
                    Persone persone = new Persone
                    {
                        PhoneNumber = pcViewModel.PhoneNumber,
                        BirthDay    = pcViewModel.BirthDay,
                        BirthMonth  = pcViewModel.BirthMonth,
                        BirthYear   = pcViewModel.BirthYear,
                        Resident    = pcViewModel.Resident,
                        RegionId    = pcViewModel.RegionId
                    };
                    // vom adauga in baza de date ambele obiecte
                    ctx.Persones.Add(persone);
                    Rezervation rezervation = new Rezervation
                    {
                        Name    = pcViewModel.Name,
                        Persone = persone
                    };
                    ctx.Rezervations.Add(rezervation);
                    ctx.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(pcViewModel));
            }
            catch (Exception e)
            {
                var msg = e.Message;
                return(View(pcViewModel));
            }
        }
        /// <summary>
        /// Creates a booking for the client account.
        /// </summary>
        /// <param name="parameters">Rezervation creation parameters. Hold information on the client account and the rezervation.</param>
        /// <returns></returns>
        public RezervationModel CreateBooking(RezervationCreationParameters parameters)
        {
            this.ValidateBookingParameters(parameters);

            //try to get a client account first
            var clientAccount = this.dbContext.ClientAccounts.SingleOrDefault(x => x.ClientId == parameters.ClientId)?.ToModel();

            if (clientAccount == null && parameters.ClientAccount != null)
            {
                clientAccount = this.clientAccountService.Add(parameters.ClientAccount);
            }
            else if (parameters.ClientAccount == null && clientAccount == null)
            {
                throw new NotFoundException("Client account not found.");
            }

            var dbRezervation = new Rezervation()
            {
                ClientId       = clientAccount.ClientId,
                CarPlateNumber = parameters.CarPlateNumber,
                PickUpDate     = parameters.PickUpDate,
                ReturnDate     = parameters.ReturnDate,
            };

            //get the car type
            var carType = CarTypes.GetCarType(parameters.CarType);

            dbRezervation.CarType    = (int)carType.Type;
            dbRezervation.RentaltFee = carType.GetRentalFee(parameters.PickUpDate, parameters.ReturnDate);
            dbRezervation.DepositFee = carType.GetDepositFee(dbRezervation.RentaltFee);

            this.dbContext.Rezervations.Add(dbRezervation);
            this.dbContext.SaveChanges();

            return(dbRezervation.ToModel(clientAccount));
        }
Example #27
0
        public JsonResult Rezervation(string Name, string Surname, string Phone, string Date, int Hour, int Field)
        {
            //mevcut tarih saatde rezervasyon varmı kontrol et!
            //yoksa rezervasyon basarılı
            //varsa sıraya al

            using (TenisKortuUygulamaEntities Entities = new TenisKortuUygulamaEntities())
            {
                try
                {
                    FillTable();
                    Rezervation rezervation = new Rezervation();
                    Users       users       = new Users();
                    DateTime    date        = new DateTime();
                    date = Convert.ToDateTime(Date);
                    Convert.ToDateTime(Date);
                    var IsRezervationAvaible = Entities.Rezervation.FirstOrDefault(x => x.HoursId == Hour && x.Date == date);
                    if (IsRezervationAvaible != null)
                    {
                        TempData["msg"] = "<script>document.getElementById('BtnQueue').style.visibility = 'visible';document.getElementById('isFinish').innerHTML = 'Seçmeye çalıştığınız tarih ve saat doludur!'; </script>";

                        return(Json(new { Status = "Warning", Message = "İlgili tarih ve kort uygun değildir lütfen başka bir seçim yapınız yada sıraya giriniz!" }, JsonRequestBehavior.AllowGet));
                    }

                    var check = Entities.Users.FirstOrDefault(x => x.Phone == Phone);
                    if (check == null) //Daha önce hiç rezervasyon yaptırmamışsa
                    {
                        users.Name     = Name;
                        users.Surname  = Surname;  //Users tablosuna kayıt kısmı
                        users.Phone    = Phone;
                        users.isMember = false;
                        Entities.Users.Add(users); //Şimdilik veri tabanına  kayıt yaptırmadım
                        Entities.SaveChanges();
                        rezervation.HoursId     = Hour;
                        rezervation.UsersId     = users.id; //Rezervasyon tablosuna kayıt kısmı
                        rezervation.FieldsId    = Field;
                        rezervation.Date        = Convert.ToDateTime(Date);
                        rezervation.IsComplated = false;
                        Entities.Rezervation.Add(rezervation);
                        Entities.SaveChanges();
                        TempData["msg"] = "<script>document.getElementById('isFinish').innerHTML='Kaydiniz basarilidir.';</script>";
                    }
                    else
                    {
                        rezervation.HoursId     = Hour;
                        rezervation.UsersId     = check.id; //Rezervasyon tablosuna kayıt kısmı
                        rezervation.FieldsId    = Field;
                        rezervation.Date        = Convert.ToDateTime(Date);
                        rezervation.IsComplated = false;
                        Entities.Rezervation.Add(rezervation);
                        Entities.SaveChanges();
                        TempData["msg"] = "<script>document.getElementById('isFinish').innerHTML='Kaydiniz basarilidir.';</script>";
                    }

                    return(Json(new { Status = "OK", Message = "İşlem Başarılı!" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { Status = "Error", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
 public Rezervation Update(Rezervation entity)
 {
     context.Entry(entity).State = EntityState.Modified;
     context.SaveChanges();
     return(entity);
 }
        public static void PopulateDatabase()
        {
            List <DateTime> rangePeriodList = GetPeriodVacation();

            using (var context = new ModelContext())
            {
                try
                {
                    User user = new User();
                    user.Username = "******";
                    user.Password = "******";
                    context.Users.Add(user);
                    context.SaveChanges();

                    County county = new County();
                    county.Name = "Brasov";
                    context.Counties.Add(county);
                    context.SaveChanges();

                    County county2 = new County();
                    county2.Name = "Maramures";
                    context.Counties.Add(county2);
                    context.SaveChanges();

                    City city = new City();
                    city.Name   = "Rasnov";
                    city.County = context.Counties.FirstOrDefault(c => c.CountyId == 1);
                    context.Cities.Add(city);
                    context.SaveChanges();

                    City city2 = new City();
                    city2.Name  = "Baia Mare";
                    city.County = context.Counties.FirstOrDefault(c => c.CountyId == 2);
                    context.Cities.Add(city2);
                    context.SaveChanges();

                    Hotel hotel = new Hotel();
                    hotel.Name = "Pensiunea Fermecata";
                    hotel.City = context.Cities.FirstOrDefault(c => c.CityId == 1);
                    context.Hotels.Add(hotel);

                    Hotel hotel2 = new Hotel();
                    hotel2.Name = "Norocul plutitor";
                    hotel2.City = context.Cities.FirstOrDefault(c => c.CityId == 2);
                    context.Hotels.Add(hotel2);
                    context.SaveChanges();

                    RoomType singleRoomType = new RoomType();
                    singleRoomType.Name = "Single";
                    context.RoomTypes.Add(singleRoomType);
                    context.SaveChanges();

                    RoomType doubleRoomType = new RoomType();
                    doubleRoomType.Name = "Double";
                    context.RoomTypes.Add(doubleRoomType);
                    context.SaveChanges();

                    Facility facility = new Facility();
                    facility.Name = "Air conditioner";
                    context.Facilities.Add(facility);
                    context.SaveChanges();

                    Facility facility2 = new Facility();
                    facility2.Name = "Plasma TV";
                    context.Facilities.Add(facility2);
                    context.SaveChanges();

                    Facility facility3 = new Facility();
                    facility3.Name = "Big Balcony";
                    context.Facilities.Add(facility3);
                    context.SaveChanges();

                    Facility facility4 = new Facility();
                    facility4.Name = "Refrigerator";
                    context.Facilities.Add(facility4);
                    context.SaveChanges();

                    Room room = new Room();
                    room.Price    = 180;
                    room.Hotel    = context.Hotels.FirstOrDefault(h => h.HotelId == 1);
                    room.RoomType = context.RoomTypes.FirstOrDefault(rt => rt.RoomTypeId == 1);
                    context.Rooms.Add(room);
                    context.SaveChanges();

                    Room room2 = new Room();
                    room2.Price    = 300;
                    room2.Hotel    = context.Hotels.FirstOrDefault(h => h.HotelId == 2);
                    room2.RoomType = context.RoomTypes.FirstOrDefault(rt => rt.RoomTypeId == 2);
                    context.Rooms.Add(room2);
                    context.SaveChanges();

                    Rezervation rezervation = new Rezervation();
                    rezervation.User     = context.Users.FirstOrDefault(u => u.UserId == 1);
                    rezervation.CheckIn  = rangePeriodList[0];
                    rezervation.CheckOut = rangePeriodList[1];
                    context.Rezervations.Add(rezervation);
                    context.SaveChanges();

                    var rezerv = new Rezervation()
                    {
                        CheckIn = rangePeriodList[0], CheckOut = rangePeriodList[1]
                    };
                    var specialRoom = new Room()
                    {
                        Price = 245
                    };
                    RezervationRoom rezervRoom = new RezervationRoom();
                    rezervRoom.Rezervation = rezerv;
                    rezervRoom.Room        = room;
                    context.RezervationRooms.Add(rezervRoom);
                    context.SaveChanges();

                    FacilityRoom facilRoom = new FacilityRoom();
                    facilRoom.Facility = context.Facilities.FirstOrDefault(f => f.FacilityId == 1);
                    facilRoom.Room     = context.Rooms.FirstOrDefault(r => r.RoomId == 1);
                    context.FacilityRooms.Add(facilRoom);
                    context.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
 public Rezervation Create(Rezervation entity)
 {
     context.Rezervations.Add(entity);
     context.SaveChanges();
     return(entity);
 }