Пример #1
0
        public async Task <IHttpActionResult> Puttbl_Alerts(int id, tbl_Alerts tbl_Alerts)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_Alerts.col_AlertID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public async Task <IHttpActionResult> PutAspNetUser(EditUserModel editUserModel)
        {
            LogApi.Log(User.Identity.GetUserId(), "UpdateUser from " + User.Identity.GetUserName() + "  " + editUserModel.FirstName + "  " +
                       "LastName " + editUserModel.LastName + "  " +
                       "House  " + editUserModel.House + "  " +
                       "Address  " + editUserModel.Address + "  " +
                       "BloodGroup  " + editUserModel.BloodGroup + "  " +
                       "City  " + editUserModel.City + "  " +
                       "DateOfBirth " + editUserModel.DateOfBirth + "  " +
                       "Department  " + editUserModel.Department + "  " +
                       "Designation  " + editUserModel.Designation + "  " +
                       "JoiningYear  " + editUserModel.JoiningYear + "  " +
                       "LeavingYear  " + editUserModel.LeavingYear + "  " +
                       "PhoneNumber  " + editUserModel.PhoneNumber + "  " +
                       "PostalCode  " + editUserModel.PostalCode + "  " +
                       "Posting  " + editUserModel.Posting + "  " +
                       "RollNo  " + editUserModel.RollNo + "  " +
                       "School  " + editUserModel.School + "  " +
                       "State  " + editUserModel.State + "  " +
                       "PhoneVisible  " + editUserModel.PhoneVisible + "  " +
                       "ShowLocation  " + editUserModel.ShowLocation + "  " +
                       "Profession  " + editUserModel.Profession + "  " +
                       "ProfileLink  " + editUserModel.ProfileLink + "  ");

            AspNetUser aspNetUser = db.AspNetUsers.Where(e => e.Id == editUserModel.Id).FirstOrDefault();

            aspNetUser.PasswordHash      = aspNetUser.PasswordHash;
            aspNetUser.SecurityStamp     = aspNetUser.SecurityStamp;
            aspNetUser.LockoutEnabled    = aspNetUser.LockoutEnabled;
            aspNetUser.LockoutEndDateUtc = aspNetUser.LockoutEndDateUtc;
            aspNetUser.TwoFactorEnabled  = aspNetUser.TwoFactorEnabled;
            aspNetUser.AccessFailedCount = aspNetUser.AccessFailedCount;
            aspNetUser.FirstName         = editUserModel.FirstName;
            aspNetUser.LastName          = editUserModel.LastName;
            aspNetUser.House             = editUserModel.House;
            aspNetUser.Address           = editUserModel.Address;
            aspNetUser.BloodGroup        = editUserModel.BloodGroup;
            aspNetUser.City         = editUserModel.City;
            aspNetUser.DateOfBirth  = editUserModel.DateOfBirth;
            aspNetUser.Department   = editUserModel.Department;
            aspNetUser.Designation  = editUserModel.Designation;
            aspNetUser.JoiningYear  = editUserModel.JoiningYear;
            aspNetUser.LeavingYear  = editUserModel.LeavingYear;
            aspNetUser.PhoneNumber  = editUserModel.PhoneNumber;
            aspNetUser.PostalCode   = editUserModel.PostalCode;
            aspNetUser.Posting      = editUserModel.Posting;
            aspNetUser.RollNo       = editUserModel.RollNo;
            aspNetUser.School       = editUserModel.School;
            aspNetUser.State        = editUserModel.State;
            aspNetUser.PhoneVisible = editUserModel.PhoneVisible;
            aspNetUser.ShowLocation = editUserModel.ShowLocation;
            aspNetUser.Profession   = editUserModel.Profession;
            aspNetUser.ProfileLink  = editUserModel.ProfileLink;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();

                try
                {
                    var token = db.tbl_DeviceIds.Where(d => d.col_UserType == "Admin").FirstOrDefault().col_DeviceToken;
                    Notifications.NotifyAsync(token, "Update", editUserModel.School + "#" + editUserModel.LeavingYear + "#" + User.Identity.GetUserId());
                }
                catch (Exception ex)
                {
                }
                return(Ok("Success"));
            }
            catch (Exception ex)
            {
                //if (!AspNetUserExists(id))
                //{
                //    return NotFound();
                //}
                //else
                //{
                //    throw;
                //}
                return(Ok(ex.Message));
            }
        }