Example #1
0
        public async Task <IActionResult> PutForm(long id, Form form)
        {
            if (id != form.Id)
            {
                return(BadRequest());
            }


            // Edit Form table
            _context.Entry(form).State = EntityState.Modified;

            // Edit headline in FormFields
            foreach (var f in form.FormFields)
            {
                _context.Entry(f).State = EntityState.Modified;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FormExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        /// <summary>
        /// update existing record with the primarykey
        /// </summary>
        /// <param name="t"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual T Update(T t, object key)
        {
            if (t == null)
            {
                return(null);
            }
            T exist = dbset.Find(key);

            if (exist != null)
            {
                repositoryContext.Entry(exist).CurrentValues.SetValues(t);
                repositoryContext.SaveChanges();
            }
            return(exist);
        }
Example #3
0
        public async Task <IActionResult> PutStudent(int id, Student student)
        {
            if (id != student.StudentId)
            {
                return(BadRequest());
            }

            _context.Entry(student).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #4
0
        public async Task <IActionResult> PutSong(Guid id, Song song)
        {
            if (id != song.SongID)
            {
                return(BadRequest());
            }

            _context.Entry(song).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SongExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #5
0
        public async Task <IActionResult> PutRecord(Guid id, Record record)
        {
            if (id != record.RecordId)
            {
                return(BadRequest());
            }

            _context.Entry(record).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecordExists(id))
                {
                    return(NotFound());
                }

                throw;
            }

            return(NoContent());
        }
Example #6
0
        public async Task <IActionResult> PutCourses(int id, Courses courses)
        {
            if (id != courses.courseId)
            {
                return(BadRequest());
            }

            _context.Entry(courses).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CoursesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #7
0
        public bool EditObjectInDatabase(object dbValues, object table)
        {
            bool blSuccess = true;

            try
            {
                _db.Entry(dbValues).CurrentValues.SetValues(table);
                if (_db.ChangeTracker.HasChanges())
                {
                    _db.SaveChanges();
                }
            }
            //catch (DbEntityValidationException ex)
            //{
            //Logger.Error("Failed Entities in SaveTableInDatabase\n" + Em.EntityErrorCapture(ex));
            //blSuccess = false;
            //}
            catch (Exception ex)
            {
                //Logger.Error("Failed SaveTableInDatabase\n" + ex);
                //Logger.Error(ex.GetAllMessages());
                //blSuccess = false;
            }
            return(blSuccess);
        }
Example #8
0
        public IHttpActionResult PutPerson(Guid id, Person person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != person.ID)
            {
                return(BadRequest());
            }

            db.Entry(person).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #9
0
        public async Task <IActionResult> PutRequest(Guid id, RequestForCreationDto requestForCreation)
        {
            if (id != requestForCreation.Id)
            {
                return(BadRequest());
            }

            var savedRequest = _mapper.Map <Request>(requestForCreation);

            var saveRequest = new Request
            {
                Description  = requestForCreation.Description,
                Priority     = requestForCreation.Priority,
                SupervisorId = requestForCreation.Supervisor,
                CreatedAt    = requestForCreation.CreatedAt,
                RequestId    = requestForCreation.Id
            };

            _context.Entry(saveRequest).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RequestExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutArtist(Guid id, Artist artist)
        {
            if (id != artist.ArtistID)
            {
                return(BadRequest());
            }

            _context.Entry(artist).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArtistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #11
0
        public async Task <IActionResult> PutOwner(Guid id, Owner owner)
        {
            if (id != owner.OwnerId)
            {
                return(BadRequest());
            }

            _context.Entry(owner).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OwnerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #12
0
        public async Task <IActionResult> PutCategory(Guid id, CategoryDto category)
        {
            if (id != category.CategoryId)
            {
                return(BadRequest());
            }

            var categoryDb = _mapper.Map <Category>(category);

            _context.Entry(categoryDb).State = EntityState.Modified;
            _context.Categories.Update(categoryDb);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(Ok());
        }
Example #13
0
        public async Task <IActionResult> PutMachine(Guid id, MachineDto machine)
        {
            if (id != machine.MachineId)
            {
                return(BadRequest());
            }
            //TODO: Update this
            _context.Entry(machine).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MachineExists(id))
                {
                    return(NotFound());
                }

                throw;
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutRole(Guid id, Role role)
        {
            if (id != role.ID)
            {
                return(BadRequest());
            }

            _context.Entry(role).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutUserInfo(Guid id, UserInfo userInfo)
        {
            if (id != userInfo.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(userInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #16
0
 /// <summary>
 /// Entity State Modified
 /// </summary>
 /// <param name="objEdit">objEdit</param>
 private void EntityStateModified(T objEdit)
 {
     if (RepositoryContext.Entry(objEdit) != null)
     {
         RepositoryContext.Entry(objEdit).State = EntityState.Modified;
     }
 }
Example #17
0
 /// <summary>
 /// EntityStateDetached
 /// </summary>
 /// <param name="obj">obj</param>
 private void EntityStateDetached(T obj)
 {
     if (obj.IsNotNull() && RepositoryContext.Entry(obj).IsNotNull())
     {
         RepositoryContext.Entry(obj).State = EntityState.Detached;
     }
 }
 public void Update(T entity)
 {
     if (!_table.Local.Contains(entity))
     {
         _table.Attach(entity);
         _repositoryContext.Entry(entity).State = EntityState.Modified;
     }
 }
Example #19
0
        public void Update(T item)
        {
            T           itemToBeUpdated = GetByID(item.ID);
            EntityEntry entry           = _context.Entry(itemToBeUpdated);

            entry.CurrentValues.SetValues(item);
            Save();
        }
Example #20
0
        public async Task <Room> Update(Room room)
        {
            var editedobject = await _context.Room.FirstOrDefaultAsync(o => o.Id == room.Id);

            _context.Entry(editedobject).CurrentValues.SetValues(room);

            await _context.SaveChangesAsync();

            return(room);
        }
Example #21
0
 public ActionResult Edit([Bind(Include = "PersonId,LastName,FirstName,MiddleName,Organization,Position,DateOfBirth")] Person person)
 {
     if (ModelState.IsValid)
     {
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(person));
 }
        public async Task <RelationDetailsEditModel> PutRelation(Guid id, RelationDetailsEditModel relationModel)
        {
            Relation relation = new Relation()
            {
                Id              = id,
                Name            = relationModel.Name,
                FullName        = relationModel.FullName,
                TelephoneNumber = relationModel.TelephoneNumber,
                EmailAddress    = relationModel.EmailAddress
            };

            RelationAddress relationAddress = new RelationAddress()
            {
                RelationId  = id,
                CountryName = relationModel.Country,
                City        = relationModel.City,
                Street      = relationModel.Street,
                Number      = relationModel.StreetNumber,
                PostalCode  = relationModel.PostalCode
            };

            _context.Entry(relation).State        = EntityState.Modified;
            _context.Entry(relationAddress).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!RelationExists(id))
                {
                    throw ex;
                }
                else
                {
                    throw;
                }
            }

            return(relationModel);
        }
        public ActionResult Edit([Bind(Include = "ContactInfoId,PhoneNumber,Email,Skype,AdditinalInfo,PersonId")] ContactInfo contactInfo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(contactInfo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new
                {
                    id = contactInfo.PersonId
                }));
            }

            return(View(contactInfo));
        }
        public ConveniosPSTRs ConveniosPST(ConveniosPSTRq body)
        {
            //var convenio = convenios.Find(c => c.Identificacion == body.Convenio.Identificacion);
            var convenio = convenioContext.Convenio.Find(body.Convenio.Identificacion);

            if (convenio == null)
            {
                convenioContext.Convenio.Attach(body.Convenio);
                convenioContext.Entry(body.Convenio).State = EntityState.Modified;

                convenioContext.Convenio.Add(body.Convenio);
                convenioContext.SaveChanges();
            }
            else
            {
                throw new ConvenioYaExisteException("El convenio ya existe");
            }

            if (convenio == null)
            {
                //convenios.Add(body.Convenio);

                ConveniosPSTRs rs = new ConveniosPSTRs {
                    Convenio = new Convenio {
                        TipoConvenio    = body.Convenio.TipoConvenio,
                        Ciudad          = body.Convenio.Ciudad,
                        Correo          = body.Convenio.Correo,
                        FechaVigencia   = body.Convenio.FechaVigencia,
                        Identificacion  = body.Convenio.Identificacion,
                        NombreProveedor = body.Convenio.NombreProveedor
                    }
                };
                return(rs);
            }
            else
            {
                throw new ConvenioNoExisteException("Ya existe el convenio");
            }
        }
Example #25
0
        public async Task <IActionResult> PutRepair(Guid id, RepairDto repairDto)
        {
            if (id != repairDto.Id)
            {
                return(BadRequest());
            }

            var repair = new Repair()
            {
                //TODO: Finalize this
                // Mechanic = await _context.Users.FindAsync(repairDto.Mechanic),
                Details       = repairDto.Details,
                Severity      = repairDto.Severity,
                ArrivalTime   = repairDto.ArrivalTime,
                DepartureTime = repairDto.DepartureTime,
                IsFixed       = repairDto.IsFixed,
                RepairId      = repairDto.Id
            };

            _context.Entry(repair).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RepairExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public void Update(TEntity obj)
 {
     Db.Entry(obj).State = EntityState.Modified;
     Db.SaveChanges();
 }
 public virtual void Update(TEntity entityToUpdate)
 {
     dbSet.Attach(entityToUpdate);
     context.Entry(entityToUpdate).State = EntityState.Modified;
 }
 public async Task Update(T entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Example #29
0
 public void Update(T entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     Save();
 }
Example #30
0
 public void UpdatePaciente(Paciente paciente)
 {
     _context.Entry(paciente).State = EntityState.Modified;
 }