Beispiel #1
0
        public async Task <IActionResult> PutMatch(int?id, Match match)
        {
            if (id != match.MatchID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutGame([FromRoute] long id, [FromBody] Game game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != game.ID || GameDeleted(id))
            {
                return(BadRequest());
            }

            dbContext.Entry(game).State = EntityState.Modified;

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

            return(NoContent());
        }
Beispiel #3
0
        public void Update(Person person)
        {
            //ctx.Persons.Update(person);
            //ctx.SaveChanges();

            ctx.Entry(person).State = EntityState.Modified;
        }
        public async Task <IActionResult> PutPractise(int?id, Practise practise)
        {
            if (id != practise.PractiseID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #5
0
        public async Task <IActionResult> PutTeam(int id, Team team)
        {
            if (id != team.TeamID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #6
0
 public ActionResult editProfile([Bind(Include = "id,name,paitientNo,symptoms,phNo")] patientsProfile patients)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patients).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(patients));
 }
 public ActionResult editDisease([Bind(Include = "id,name,symptom1,symptom2,symptom3,symptom4,cure,desc")] diseaseData disease)
 {
     if (ModelState.IsValid)
     {
         db.Entry(disease).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("viewDiseases"));
     }
     return(View(disease));
 }
        public async Task <ProfileDto> EditProfileByIdAsync(string ownerId, ProfileReq input)
        {
            try
            {
                var existingProfile = await _dbContext.ProfileModels.Include(x => x.Competences)
                                      .Include(x => x.ImageModel)
                                      .Include(x => x.ProjectProfileRoles).ThenInclude(x => x.ProjectModel).ThenInclude(x => x.TimePeriod)
                                      .Include(x => x.ProjectProfileRoles).ThenInclude(x => x.ProjectModel).ThenInclude(x => x.Techniques)
                                      .FirstOrDefaultAsync(x => x.OwnerID == ownerId);

                if (input.OfficeModelId != 0)
                {
                    _dbContext.Entry(existingProfile).Property("OfficeModelId").CurrentValue = input.OfficeModelId;
                }

                existingProfile.AboutMe     = input.AboutMe;
                existingProfile.FirstName   = input.FirstName;
                existingProfile.LastName    = input.LastName;
                existingProfile.Position    = input.Position;
                existingProfile.LinkedInUrl = input.LinkedInUrl;
                existingProfile.ResumeUrl   = input.ResumeUrl;
                existingProfile.Modified    = DateTime.UtcNow;
                foreach (var competence in input.Competences)
                {
                    var existingCompetence = existingProfile.Competences.FirstOrDefault(c => c.Id == competence.Id);
                    if (existingCompetence == null)
                    {
                        existingProfile.Competences.Add(competence);
                    }
                    else
                    {
                        _dbContext.Entry(existingCompetence).CurrentValues.SetValues(competence);
                    }
                }

                foreach (var competence in existingProfile.Competences)
                {
                    if (!input.Competences.Any(c => c.Id == competence.Id))
                    {
                        _dbContext.Remove(competence);
                    }
                }
                _dbContext.Update(existingProfile);
                await _dbContext.SaveChangesAsync();

                return(_mapper.Map <ProfileModel, ProfileDto>(existingProfile));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public async Task <IActionResult> PutPlayer(int id, Player player)
        {
            if (id != player.PlayerID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public MerchantVM Update(MerchantVM mvm)
        {
            Merchant merchant = db.Merchants.Find(mvm.MerchantID);

            merchant.CompanyName       = mvm.CompanyName;
            merchant.ProprietorName    = mvm.ProprietorName;
            merchant.Password          = mvm.Password;
            merchant.Mobile            = mvm.Mobile;
            merchant.AlternativeMobile = mvm.AlternativeMobile;
            merchant.FbLink            = mvm.FbLink;
            merchant.Address           = mvm.Address;
            merchant.WebSiteName       = mvm.WebSiteName;
            merchant.BankAccount       = mvm.BankAccount;
            merchant.BussinessType     = mvm.BussinessType;
            merchant.Location          = mvm.Location;
            merchant.AccountHolderName = mvm.AccountHolderName;
            merchant.District          = mvm.District;
            merchant.BankName          = mvm.BankName;
            merchant.BranchName        = mvm.BranchName;
            merchant.RoutingNumber     = mvm.RoutingNumber;

            db.Entry(merchant).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(mvm);
        }
        public virtual async Task <TEntity> GetByIdNoTracking(int id)
        {
            var entity = await DbSet.FindAsync(id);

            Db.Entry(entity).State = EntityState.Detached;
            return(entity);
        }
Beispiel #12
0
        public async Task <IActionResult> PutValue(int id, Value value)
        {
            if (id != value.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #13
0
        public async Task <IActionResult> PutCategory([FromRoute] int id, [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != category.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #14
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #15
0
        public Task Update(T entity)
        {
            entity.ModifiedDate = DateTime.Now;

            // In case AsNoTracking is used
            Context.Entry(entity).State = EntityState.Modified;
            return(Context.SaveChangesAsync());
        }
Beispiel #16
0
        public async Task <IActionResult> EditPost(Post post)
        {
            await _context.Posts.AddAsync(post);

            _context.Entry(post).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            await _context.SaveChangesAsync();

            return(RedirectToAction("ManagePost", "Manage"));
        }
Beispiel #17
0
        public IActionResult PutPart(int id, [FromBody] Part part)
        {
            if (!ModelState.IsValid)
            {
                return(HttpBadRequest(ModelState));
            }

            if (id != part.ID)
            {
                return(HttpBadRequest());
            }

            DateTime?lastMod         = _context.Parts.AsNoTracking().Where(x => x.ID == part.ID).FirstOrDefault().LastTimeModified;
            DateTime comparationDate = DateTime.Now.AddHours(-4);

            if (lastMod < comparationDate) //jeœli poprzednia modyfikacja by³a ju¿ dawno, zrób kopiê
            {
                PartBackup newPB = new PartBackup();
                newPB.Define(_context.Entry(part).Entity);
                _context.Add(newPB);
            }

            part.LastTimeModified = DateTime.Now;

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

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PartExists(id))
                {
                    return(HttpNotFound());
                }
                else
                {
                    throw;
                }
            }

            return(new HttpStatusCodeResult(StatusCodes.Status204NoContent));
        }
        public ActionResult Dashboard(PersonalInformation user)
        {
            using (var dbContext = new DataDbContext())
            {
                var getPopulationList  = dbContext.Populations.ToList();
                var getGenderList      = dbContext.Gender.ToList();
                var getNationalityList = dbContext.Nationalities.ToList();
                var getMaritalList     = dbContext.MaritalStatus.ToList();
                var getAppFieldList    = dbContext.ApplicationField.ToList();
                var getAppTypeList     = dbContext.ApplicationType.ToList();


                SelectList PopulationList  = new SelectList(getPopulationList, "PkPopulationId", "PopulationValue");
                SelectList GenderList      = new SelectList(getGenderList, "PkGenderId", "GenderValue");
                SelectList NationalityList = new SelectList(getNationalityList, "PkNationalityId", "NationalityValue");
                SelectList MaritalList     = new SelectList(getMaritalList, "PkMaritalStatusId", "MaritalStatusValue");
                SelectList AppFieldList    = new SelectList(getAppFieldList, "PkApplicationFieldId", "FieldName");
                SelectList AppTypeList     = new SelectList(getAppTypeList, "PkApplicationTypeId", "ApplicationTypeName");


                ViewData["Population"]  = PopulationList;
                ViewData["Gender"]      = GenderList;
                ViewData["Nationality"] = NationalityList;
                ViewData["Marital"]     = MaritalList;
                ViewData["AppType"]     = AppTypeList;
                ViewData["AppField"]    = AppFieldList;



                if (ModelState.IsValid)
                {
                    // Hashing Password before it is saved
                    var HashPassword = new Hashing();
                    user.New_Password    = HashPassword.HashPassword(user.New_Password);
                    user.ConfirmPassword = HashPassword.HashPassword(user.ConfirmPassword);


                    string fileName      = Path.GetFileNameWithoutExtension(user.ImageFile.FileName);
                    string fileExtension = Path.GetExtension(user.ImageFile.FileName);
                    fileName       = fileName + DateTime.Now.ToString("yymmssfff") + fileExtension;
                    user.ImagePath = "~/ApplicantsImages/" + fileName;

                    fileName = Path.Combine(Server.MapPath("~/ApplicantsImages/"), fileName);
                    user.ImageFile.SaveAs(fileName);

                    dbContext.Entry(user).State = EntityState.Modified;
                    dbContext.SaveChanges();
                    ViewBag.Updated = "Successfully Updated User. Login required";
                    return(RedirectToAction("Dashboard", "Applicant"));
                }
                else
                {
                    return(View(user));
                }
            }
        }
 public ActionResult Edit([Bind(Include = "ProductId,Name,Weight,Price")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
        public ColorVM Update(ColorVM cvm)
        {
            Color color = db.Colors.Find(cvm.ID);

            color.Name = cvm.Name;

            db.Entry(color).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(cvm);
        }
Beispiel #21
0
 public void Update(TEntity entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     Dbset.Attach(entity);
     _dataContext.Entry(entity).State = EntityState.Modified;
     SaveChanges();
 }
 public ActionResult Edit([Bind(Include = "CartId,DateAndTime")] Cart cart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cart).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cart));
 }
        public ProductRatingVM Update(ProductRatingVM rvm)
        {
            ProductRating productRating = db.ProductRatings.Find(rvm.ID);

            productRating.ProductID = rvm.ProductID;
            productRating.Star      = rvm.Star;

            db.Entry(productRating).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(rvm);
        }
Beispiel #24
0
        public OrderStatusVM Update(OrderStatusVM svm)
        {
            OrderStatus orderStatus = db.OrderStatuses.Find(svm.ID);

            orderStatus.Caption  = svm.Caption;
            orderStatus.IsActive = svm.IsActive;

            db.Entry(orderStatus).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(svm);
        }
Beispiel #25
0
 public CategoryVM Update(CategoryVM cvm)
 {
     Category category = db.Categories.Find(cvm.ID);
     category.Name = cvm.Name;
     category.ParentCategoryID = Convert.ToInt64(cvm.ParentCategoryID);
     category.DisplayOrder = Convert.ToInt64(cvm.DisplayOrder);
     category.IsActive = Convert.ToBoolean(cvm.IsActive);
     db.Entry(category).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     db.SaveChanges();
     return cvm;
 }
Beispiel #26
0
        public BrandVM Update(BrandVM bvm)
        {
            Brand brand = db.Brands.Find(bvm.ID);

            brand.BandName        = bvm.BandName;
            brand.CategoryID      = bvm.CategoryID;
            brand.ParentBandID    = bvm.ParentBandID;
            db.Entry(brand).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(bvm);
        }
 public ActionResult Edit([Bind(Include = "CartItemId,Amount,CartId,ProductId")] CartItem cartItem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cartItem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CartId    = new SelectList(db.Cart, "CartId", "CartId", cartItem.CartId);
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Name", cartItem.ProductId);
     return(View(cartItem));
 }
Beispiel #28
0
        public async Task <IActionResult> PutTeam([FromRoute] long gameId, [FromRoute] long teamId, [FromBody] Team team)
        {
            team.Game = dbContext.Games.Where(g => g.ID == gameId).FirstOrDefault();
            if (team.Game == null)
            {
                return(BadRequest("Game ID Incorrect"));
            }
            ModelState.Clear();
            TryValidateModel(team);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (teamId != team.ID || TeamDeleted(team.ID))
            {
                return(BadRequest());
            }

            dbContext.Entry(team).State = EntityState.Modified;

            try
            {
                await dbContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamExists(teamId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ProductReviewVM Update(ProductReviewVM rvm)
        {
            ProductReview productReview = db.ProductReviews.Find(rvm.ID);

            productReview.ProductID        = rvm.ProductID;
            productReview.UserID           = rvm.UserID;
            productReview.fkUserReviewGave = rvm.fkUserReviewGave;
            productReview.Review           = rvm.Review;
            productReview.ReviewDate       = rvm.ReviewDate;
            productReview.IsApproved       = rvm.IsApproved;

            db.Entry(productReview).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(rvm);
        }
Beispiel #30
0
        public OrderDetailsVM Update(OrderDetailsVM odvm)
        {
            OrderDetails orderDetails = db.OrderDetails.Find(odvm.ID);

            orderDetails.OrderID        = odvm.OrderID;
            orderDetails.ProductID      = odvm.ProductID;
            orderDetails.ShipingDate    = odvm.ShipingDate;
            orderDetails.SigleItemPrice = odvm.SigleItemPrice;
            orderDetails.State          = odvm.State;
            orderDetails.Quantity       = odvm.Quantity;

            db.Entry(orderDetails).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            db.SaveChanges();
            return(odvm);
        }