text:
using System.Web;
using System.Web.Mvc;
using BeautyTeamWeb.Models;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using System.Configuration;
using System.ComponentModel.DataAnnotations;
using BeautyTeamWeb.ViewModels;
using System.IO;
using System;
using BeautyTeamWeb.Services;
using System.Collections.Generic;
using System.Linq;
using static BeautyTeamWeb.Services.WeChatService;

namespace BeautyTeamWeb.Controllers
{
    [RequireHttps]
    public class ApiController : ControllerWithAuthorize
    {
        #region Account Management API
        // GET: /api
        public async Task<string> Index()
        {
            return await this._apiReplyTool(async () =>
            {
                return await MessageAsync("Welcome to BeautyTeam API!", HttpStatusCode.OK);
            });
        }

        [HttpPost]
        // POST: /api/Log
        public async Task<string> Log(EventLog eventLog)
        {
            return await this._apiReplyTool(async () =>
            {
                //Create Database Model
                var log = new EventLogDb(eventLog);
                DbContext.EventLogDbs.Add(log);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [HttpPost]
        // POST: /api/Login
        public async Task<string> Login(LoginViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe ?? false, shouldLockout: false);
                switch (result)
                {
                    case SignInStatus.Success:
                        return await MessageAsync("Success", HttpStatusCode.OK);
                    case SignInStatus.LockedOut:
                        return await MessageAsync("LockedOut", HttpStatusCode.Forbidden);
                    case SignInStatus.RequiresVerification:
                        return await MessageAsync("RequiresVerification", HttpStatusCode.Redirect);
                    case SignInStatus.Failure:
                    default:
                        return await MessageAsync("Failure", HttpStatusCode.Forbidden);
                }
            });
        }

        [HttpPost]
        // POST: /api/ForgotPassword
        public async Task<string> ForgotPassword(ForgotPasswordViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var user = await UserManager.FindByEmailAsync(model.Email);
                //Not Found
                if (user == null)
                {
                    return NotFoundResult;
                }
                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                await UserManager.SendEmailAsync(user.Id, "Reset Password", $"Please reset your password by clicking here");
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/VerifyEmail
        public async Task<string> VerifyEmail()
        {
            return await this._apiReplyTool(async () =>
            {
                var user = await userAsync();
                //Already Confirmed
                if (user.EmailConfirmed)
                {
                    return ForbiddenResult;
                }
                //Send Email
                else
                {
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking here");
                }
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/ChangePassword
        public async Task<string> ChangePassword(ChangePasswordViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
                if (result.Succeeded)
                {
                    var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                    if (user != null)
                    {
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    }
                    return OkResult;
                }
                //Wrong password
                return ForbiddenResult;
            });
        }

        [ApiAuthorize]
        // GET: /api/CurrentUser
        public async Task<string> CurrentUser()
        {
            return await this._apiReplyTool(async () =>
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                return await _JsongAsync(new ObiObject<ObisoftUser> { Object = user, StatusCode = HttpStatusCode.OK });
            });
        }

        // GET: /api/AnotherUser
        public async Task<string> AnotherUser(string id/*User Id*/)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await UserManager.FindByIdAsync(id);
                //Not Found
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //Return
                var Result = new AnotherUser
                {
                    Id = Target.Id,
                    Description = Target.Description,
                    Email = Target.Email,
                    RealName = Target.RealName,
                    IconImage = Target.IconImage,
                    NickName = Target.NickName,
                    UserName = Target.UserName
                };
                return await _JsongAsync(new ObiObject<AnotherUser>
                {
                    Object = Result,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [HttpPost]
        // POST: /api/Register
        public async Task<string> Register(RegisterViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var user = new ObisoftUser
                {
                    UserName = model.Email,
                    Email = model.Email,
                    NickName = model.Email.Split('@')[0]
                };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking here");
                    return OkResult;
                }
                return ConflictSetResult;
            });
        }

        // GET: /api/loginstatus
        public async Task<string> loginstatus()
        {
            return await this._apiReplyTool(async () =>
            {
                bool status = User.Identity.IsAuthenticated;
                return await _JsongAsync(new ObiValue<bool> { StatusCode = HttpStatusCode.OK, Value = status });
            });
        }

        [HttpPost]
        // POST: /api/logoff
        public async Task<string> logoff()
        {
            return await this._apiReplyTool(async () =>
            {
                HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                await System.Threading.Tasks.Task.Delay(0);
                return OkResult;
            });
        }

        // GET: /api/latestversion?Platform=android&CurrentVersion=0.0.1
        public async Task<string> latestversion(VersionCheckModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                string LatestVersion = string.Empty;
                string LatestVersionDescription = string.Empty;
                switch (model.Platform.Trim().ToLower())
                {
                    case "android":
                        LatestVersion = ConfigurationManager.AppSettings["AndroidVersion"];
                        LatestVersionDescription = ConfigurationManager.AppSettings["AndroidVersionDes"];
                        break;
                    case "ios":
                        LatestVersion = ConfigurationManager.AppSettings["iOSVersion"];
                        LatestVersionDescription = ConfigurationManager.AppSettings["iOSVersionDes"];
                        break;
                    case "uwp":
                        LatestVersion = ConfigurationManager.AppSettings["UWPVersion"];
                        LatestVersionDescription = ConfigurationManager.AppSettings["UWPVersionDes"];
                        break;
                    case "wpf":
                        LatestVersion = ConfigurationManager.AppSettings["WPFVersion"];
                        LatestVersionDescription = ConfigurationManager.AppSettings["WPFVersionDes"];
                        break;
                    default:
                        return NotFoundResult;
                }
                var result = new VersionCheckResult
                {
                    StatusCode = HttpStatusCode.OK,
                    IsLatest = LatestVersion.Trim().ToLower() == (model?.CurrentVersion?.Trim()?.ToLower() ?? string.Empty),
                    LatestVersion = LatestVersion,
                    LatestVersionDescription = LatestVersionDescription
                };
                return await _JsongAsync(result);
            });
        }

        // GET: /api/FindUserByEmail?Email=mma%40obisoft.com.cn
        public async Task<string> FindUserByEmail([DataType(DataType.EmailAddress)]string Email)
        {
            return await this._apiReplyTool(async () =>
            {
                var user = await UserManager.FindByEmailAsync(Email);
                if (user == null)
                {
                    return NotFoundResult;
                }
                return await _JsongAsync(new ObiObject<string>
                {
                    Object = user.Id,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [ApiAuthorize]
        // POST: /api/SetBasicInfo
        public async Task<string> SetBasicInfo(BasicInfoViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                cuser.PhoneNumber = model.PhoneNumber ?? cuser.PhoneNumber;
                cuser.NickName = model.NickName ?? cuser.NickName;
                cuser.RealName = model.RealName ?? cuser.RealName;
                cuser.IconImage = model.IconImage ?? cuser.IconImage;
                cuser.Description = model.Description ?? cuser.Description;
                await UserManager.UpdateAsync(cuser);
                return OkResult;
            });
        }

        // GET: /api/_Unauthorized
        public async Task<string> _Unauthorized()
        {
            return await _JsongAsync(new ServerReply { StatusCode = HttpStatusCode.Unauthorized });
        }

        [HttpPost]
        // POST: /api/UploadImage
        public async Task<string> UploadImage(UploadImageViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var file = Request.Files["file"];
                var fileExtension = Path.GetExtension(file.FileName).ToLower();
                var result = string.Empty;
                if (file != null)
                {
                    if (Directory.Exists(Server.MapPath("~/TempUpload")) == false)
                        Directory.CreateDirectory(Server.MapPath("~/TempUpload"));
                    var fileName = file.FileName.CreatePasswordHash(4) + fileExtension;
                    var virpath = HttpContext.Server.MapPath("~/TempUpload") + @"\" + fileName;
                    file.SaveAs(virpath);
                    result = await OSSService.Upload(fileName, virpath, model.UnCompressed, model.HTTPS);
                }
                return await MessageAsync(result, HttpStatusCode.OK); ;
            });
        }
        #endregion

        #region School Management API
        // GET: /api/SchoolList
        public async Task<string> SchoolList()
        {
            return await this._apiReplyTool(async () =>
            {
                var List = SchoolService.Schools;
                return await _JsongAsync(new ObiList<School>
                {
                    List = List,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        // GET: /api/SchoolDetail/1
        public async Task<string> SchoolDetail(int? id)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = SchoolService.FindSchoolById(id);
                if (Target == null)
                {
                    return NotFoundResult;
                }
                return await _JsongAsync(new ObiObject<School>
                {
                    Object = Target,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/BindSchool/1
        public async Task<string> BindSchool(int? id)
        {
            return await this._apiReplyTool(async () =>
            {
                if (SchoolService.FindSchoolById(id) == null)
                {
                    return NotFoundResult;
                }
            (await userAsync()).SchoolId = id;
                (await userAsync()).SchoolAccount = string.Empty;
                (await userAsync()).SchoolPassAes = string.Empty;
                await UserManager.UpdateAsync(await userAsync());
                return OkResult;
            });
        }

        // POST: /api/SetSchoolAccount
        [HttpPost]
        [ApiAuthorize]
        public async Task<string> SetSchoolAccount(SetSchoolAccount model)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                if (cuser.SchoolBinded)
                {
                    if (await cuser.UserSchool().IsCorrectAccount(model.Account, model.Password))
                    {
                        cuser.SchoolAccount = model.Account;
                        cuser.SchoolPassAes = model.Password.AESEncrypt();
                        await UserManager.UpdateAsync(cuser);
                        return OkResult;
                    }
                    else
                    {
                        //Wrong Password
                        return await _JsongAsync(new ServerReply { StatusCode = HttpStatusCode.BadRequest });
                    }
                }
                else
                {
                    //Not Binded
                    return await _JsongAsync(new ServerReply { StatusCode = HttpStatusCode.Forbidden });
                }
            });
        }
        #endregion

        #region Team Management API
        [ApiAuthorize]
        // GET: /api/StatisticInfo
        public async Task<string> StatisticInfo()
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                int PeopleYouLeading = 0;
                cuser.GU_Relations.Where(t => (short)t.RelationType <= 3).ToList().ForEach((GU_Relation t) => PeopleYouLeading += t.Group.GU_Relations.Count - 1);
                int TaskFinished = cuser.TU_Relations.Where(t => t.GroupTask.DeadLine < DateTime.Now).Count();
                var Model = new TeamStatisticInfo
                {
                    Joined = cuser.GU_Relations.Count(),
                    Owned = cuser.GU_Relations.Where(t => t.RelationType == GU_RelationType.Owner).Count(),
                    Admined = cuser.GU_Relations.Where(t => (short)t.RelationType <= 3).Count(),
                    Teams = cuser.GU_Relations.Where(t => t.Group is Team).Count(),
                    InfoStations = cuser.GU_Relations.Where(t => t.Group is RadioStation).Count(),
                    PeopleYouLeading = PeopleYouLeading,
                    TaskFinished = TaskFinished
                };
                return await _JsongAsync(new ObiObject<TeamStatisticInfo>
                {
                    Object = Model,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/CreateTeam
        public async Task<string> CreateTeam(CreateTeamModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var newTeam = new Team
                {
                    GroupName = model.TeamName,
                    GroupDescription = model.TeamDescription,
                    CreateTime = DateTime.Now,
                    GroupType = model.GroupType
                };
                DbContext.Groups.Add(newTeam);
                await DbContext.SaveChangesAsync();
                //Set him as the owner
                DbContext.GU_Relation.Add(new GU_Relation
                {
                    ObisoftUserId = User.Identity.GetUserId(),
                    GroupId = newTeam.GroupId,
                    RelationType = GU_RelationType.Owner
                });
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = newTeam.GroupId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/CreateRadioStation
        public async Task<string> CreateRadioStation(CreateRadioStationModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var newRadioStation = new RadioStation
                {
                    GroupName = model.RadioStationName,
                    GroupDescription = model.RadioStationDescription,
                    CreateTime = DateTime.Now,
                    GroupType = model.GroupType
                };
                DbContext.Groups.Add(newRadioStation);
                await DbContext.SaveChangesAsync();
                //Set him as the owner
                DbContext.GU_Relation.Add(new GU_Relation
                {
                    ObisoftUserId = User.Identity.GetUserId(),
                    GroupId = newRadioStation.GroupId,
                    RelationType = GU_RelationType.Owner
                });
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = newRadioStation.GroupId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/DeleteGroup
        public async Task<string> DeleteGroup(int? id)//Group Id
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id);
                //Not Found the group
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //User is not the owner.
                var MyRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null || MyRelation.RelationType != GU_RelationType.Owner)
                {
                    return ForbiddenResult;
                }
                DbContext.Groups.Remove(Target);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/JoinGroup/5
        public async Task<string> JoinGroup(int? id)//Group Id
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id);
                //Not found the team.
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //Already have some relation
                else if (Target.GU_Relations.Exists(t => t.ObisoftUserId == User.Identity.GetUserId()))
                {
                    return ConflictSetResult;
                }
                else
                {
                    //Join the Group
                    DbContext.GU_Relation.Add(new GU_Relation
                    {
                        ObisoftUserId = User.Identity.GetUserId(),
                        GroupId = Target.GroupId,
                        RelationType = GU_RelationType.Member
                    });
                    await DbContext.SaveChangesAsync();
                    return OkResult;
                }
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/LeaveGroup
        public async Task<string> LeaveGroup(int? id)//Gourp Id
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id);
                //Not Found the team.
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //Do Not have some relation
                var MyRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null)
                {
                    return ConflictSetResult;
                }
                //If he is the owner, destroy the group.
                else if (MyRelation.RelationType == GU_RelationType.Owner)
                {
                    DbContext.Groups.Remove(Target);
                }
                //Found relation and going to delete.
                DbContext.GU_Relation.Remove(MyRelation);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [ApiAuthorize]
        // GET: /api/Groupsijoined
        public async Task<string> Groupsijoined()
        {
            return await this._apiReplyTool(async () =>
            {
                var Result = new List<GU_RelationR>();
                (await userAsync()).GU_Relations.ForEach((GU_Relation t) => Result.Add(new GU_RelationR(t)));
                return await _JsongAsync(new ObiList<GU_RelationR>
                {
                    List = Result,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/SetAdmin
        public async Task<string> SetAdmin(int? id/*Group Id*/, SetGroupAdminModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id);
                //Group Not Found or User not found
                if (Target == null || UserManager.FindById(model.TargetUserId) == null)
                {
                    return NotFoundResult;
                }

                //Not Authorized, I am not the owner.
                var MyRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null || MyRelation.RelationType != GU_RelationType.Owner)
                {
                    return ForbiddenResult;
                }

                //He is already an Owner or He is already an admin
                var TRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == model.TargetUserId);
                if (TRelation == null || (TRelation.RelationType == GU_RelationType.Owner || TRelation.RelationType == GU_RelationType.Admin))
                {
                    return ConflictSetResult;
                }

                //Change the relation
                TRelation.RelationType = GU_RelationType.Admin;
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        // GET: /api/GroupDetails
        public async Task<string> GroupDetails(int? id)//Group Id
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id);
                //Group Not Found
                if (Target == null)
                {
                    return NotFoundResult;
                }
                return await _JsongAsync(new ObiObject<Group>
                {
                    Object = Target,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [ApiAuthorize]
        // GET: api/TeamProjects
        public async Task<string> TeamProjects(int? id)//Team Id
        {
            return await this._apiReplyTool(async () =>
            {
                var TargetTeam = await DbContext.Groups.FindAsync(id) as Team;
                if (TargetTeam == null)
                {
                    return NotFoundResult;
                }
                //Not Authorized
                var MyRelation = TargetTeam.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null)
                {
                    return ForbiddenResult;
                }
                return await _JsongAsync(new ObiList<Project>
                {
                    StatusCode = HttpStatusCode.OK,
                    List = TargetTeam.GroupProjects
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/BootUser
        public async Task<string> BootUser(int? id/*GroupId*/, BootUserModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id);

                //Group Not Found or User not found or I just did not join the group or he did not join the group.
                if (Target == null || UserManager.FindById(model.TargetUserId) == null)
                {
                    return NotFoundResult;
                }

                //Not Authorized, I am not the owner and I am not the admin
                var MyRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null || (MyRelation.RelationType != GU_RelationType.Owner && MyRelation.RelationType != GU_RelationType.Admin))
                {
                    return ForbiddenResult;
                }

                //I am not the owner and I want to kick an admin
                var TRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == model.TargetUserId);
                if (TRelation == null || (MyRelation.RelationType != GU_RelationType.Owner && TRelation.RelationType == GU_RelationType.Admin))
                {
                    return ConflictSetResult;
                }

                //I want to boot myself
                if (TRelation.GU_RelationId == MyRelation.GU_RelationId)
                {
                    return ConflictSetResult;
                }

                //Change the relation
                DbContext.GU_Relation.Remove(TRelation);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [ApiAuthorize]
        // GET: /api/SearchGroup
        public async Task<string> SearchGroup([Required]string keyword, bool? isTeamNotRadioStation)
        {
            return await this._apiReplyTool(async () =>
            {
                List<Group> result = null;
                if (isTeamNotRadioStation == true)
                {
                    result = DbContext.Groups.Where(t => t.GroupName.Contains(keyword) && t is Team).ToList();
                }
                else
                {
                    result = DbContext.Groups.Where(t => t.GroupName.Contains(keyword) && t is RadioStation).ToList();
                }
                return await _JsongAsync(new ObiList<Group>
                {
                    StatusCode = HttpStatusCode.OK,
                    List = result
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/CreateProject
        public async Task<string> CreateProject(int? id/*Team (Group) Id*/, CreateProjectModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id) as Team;
                //Can not find target team.
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //I am not an admin and I am not an owner.
                var MyRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null || (MyRelation.RelationType != GU_RelationType.Owner && MyRelation.RelationType != GU_RelationType.Admin))
                {
                    return ForbiddenResult;
                }
                //Create new Project
                var NewProject = new Project
                {
                    GroupId = Target.GroupId,
                    ProjectDescription = model.ProjectDescription,
                    ProjectName = model.ProjectName,
                };
                Target.GroupProjects.Add(NewProject);
                await DbContext.SaveChangesAsync();
                //Return Project Id
                return await _JsongAsync(new ObiValue<int>
                {
                    Value = NewProject.ProjectId,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/DeleteProject
        public async Task<string> DeleteProject(int? id/*Project Id*/)
        {
            return await this._apiReplyTool(async () =>
            {
                var TargetProject = await DbContext.Projects.FindAsync(id);
                //Not found this project
                if (TargetProject == null)
                {
                    return NotFoundResult;
                }
                //Unauthorized
                var TargetGroup = TargetProject.Group;
                var MyRelation = TargetGroup.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                //I am not the owner and I am not the admin
                if (MyRelation == null || (MyRelation.RelationType != GU_RelationType.Admin && MyRelation.RelationType != GU_RelationType.Owner))
                {
                    return ForbiddenResult;
                }
                DbContext.Projects.Remove(TargetProject);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
#warning Not Implemented!!!!
        // POST: /api/CreateTeamTask
        public async Task<string> CreateTeamTask(int? id /*Project Id*/, CreatePersonalTaskModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var TargetProject = await DbContext.Projects.FindAsync(id);
                //Not found this project
                if (TargetProject == null)
                {
                    return NotFoundResult;
                }
                //Unauthorized
                var TargetGroup = TargetProject.Group;
                var MyRelation = TargetGroup.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null)
                {
                    return ForbiddenResult;
                }
                return "";

            });
        }
        #endregion

        #region Personal Events And Tasks API
        [HttpPost]
        [ApiAuthorize]
        // POST: /api/CreatePersonalTask
        public async Task<string> CreatePersonalTask(CreatePersonalTaskModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                if (model.NoticeBefore.OutOfRange())
                {
                    return NotAcceptableResult;
                }
                var newPersonalTask = new PersonalTask
                {
                    DeadLine = model.DeadLine ?? DateTime.Now + new TimeSpan(days: 5, hours: 0, minutes: 0, seconds: 0),
                    Before = model.NoticeBefore ?? new TimeSpan(hours: 23, minutes: 59, seconds: 59),
                    ObisoftUserId = User.Identity.GetUserId(),
                    TaskName = model.TaskName,
                    TaskContent = model.TaskContent
                };
                DbContext.PersonalTasks.Add(newPersonalTask);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = newPersonalTask.TaskId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/CreatePersonalEvent
        public async Task<string> CreatePersonalEvent(CreatePersonalEventModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                if (model.NoticeBefore.OutOfRange())
                {
                    return NotAcceptableResult;
                }
                var newPersonalEvent = new PersonalEvent
                {
                    HappenTime = model.HappenTime ?? DateTime.Now + new TimeSpan(days: 5, hours: 0, minutes: 0, seconds: 0),
                    EndTime = model.EndTime ?? DateTime.Now + new TimeSpan(days: 6, hours: 0, minutes: 0, seconds: 0),
                    Before = model.NoticeBefore ?? new TimeSpan(hours: 0, minutes: 25, seconds: 0),
                    ObisoftUserId = User.Identity.GetUserId(),
                    EventContent = model.EventContent,
                    EventName = model.EventName
                };
                DbContext.PersonalEvents.Add(newPersonalEvent);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = newPersonalEvent.EventId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/DeletePersonalTask
        public async Task<string> DeletePersonalTask(int? id)//TaskId
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.PersonalTasks.FindAsync(id);
                if (Target == null)
                {
                    return NotFoundResult;
                }
                else if (Target.ObisoftUserId != User.Identity.GetUserId())
                {
                    return ForbiddenResult;
                }
                else
                {
                    DbContext.PersonalTasks.Remove(Target);
                    await DbContext.SaveChangesAsync();
                    return OkResult;
                }
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/DeletePersonalEvent
        public async Task<string> DeletePersonalEvent(int? id)//EventId
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.PersonalEvents.FindAsync(id);
                if (Target == null)
                {
                    return NotFoundResult;
                }
                else if (Target.ObisoftUserId != User.Identity.GetUserId())
                {
                    return ForbiddenResult;
                }
                else
                {
                    DbContext.PersonalEvents.Remove(Target);
                    await DbContext.SaveChangesAsync();
                    return OkResult;
                }
            });
        }

        [ApiAuthorize]
        // GET: /api/PersonalTaskDetails
        public async Task<string> PersonalTaskDetails(int? id)//Task Id
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.PersonalTasks.FindAsync(id);
                if (Target == null)
                {
                    return NotFoundResult;
                }
                else if (Target.ObisoftUserId != User.Identity.GetUserId())
                {
                    return ForbiddenResult;
                }
                else
                {
                    return await _JsongAsync(new ObiObject<PersonalTask>
                    {
                        Object = Target,
                        StatusCode = HttpStatusCode.OK
                    });
                }
            });
        }

        [ApiAuthorize]
        // GET: /api/PersonalEventDetails
        public async Task<string> PersonalEventDetails(int? id)//Event Id
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.PersonalEvents.FindAsync(id);
                if (Target == null)
                {
                    return NotFoundResult;
                }
                else if (Target.ObisoftUserId != User.Identity.GetUserId())
                {
                    return ForbiddenResult;
                }
                else
                {
                    return await _JsongAsync(new ObiObject<PersonalEvent>
                    {
                        Object = Target,
                        StatusCode = HttpStatusCode.OK
                    });
                }
            });
        }

        [ApiAuthorize]
        // GET: /api/AllNoticeForMe
        public async Task<string> AllNoticeForMe(int? Amount)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                List<INoticeable> Notice = new List<INoticeable>();
                //Add all his PersonalTasks which deads later
                foreach (INoticeable t in cuser.PersonalTasks.Where(t => t.DeadLine > DateTime.Now))
                {
                    Notice.Add(t);
                }
                //Add all his PersonalEvents which happens later
                foreach (INoticeable e in cuser.PersonalEvents.Where(t => t.EndTime > DateTime.Now))
                {
                    Notice.Add(e);
                }
                //Add all his GroupTasks which deads later
                foreach (var TURelation in cuser.TU_Relations.Where(t => t.GroupTask.DeadLine > DateTime.Now))
                {
                    Notice.Add(TURelation.GroupTask);
                }
                //Add all his GroupEvents which happens later
                foreach (var EURelation in cuser.EU_Relations.Where(t => t.GroupEvent.EndTime > DateTime.Now))
                {
                    Notice.Add(EURelation.GroupEvent);
                }
                //For all his radiostations he joined
                foreach (var Group in cuser.GU_Relations.Where(t => t.Group is RadioStation))
                {
                    //Add RadioTasks which deads later
                    foreach (var t in (Group.Group as RadioStation).RadioTasks.Where(t => t.DeadLine > DateTime.Now))
                    {
                        Notice.Add(t);
                    }
                    //Add RadioEvent which happens later
                    foreach (var e in (Group.Group as RadioStation).RadioEvents.Where(t => t.EndTime > DateTime.Now))
                    {
                        Notice.Add(e);
                    }
                }
                return await _JsongAsync(new ObiList<INoticeable>
                {
                    List = Notice.OrderByDescending(t => t.NoticeDate).Take(Amount ?? 10),
                    StatusCode = HttpStatusCode.OK
                });
            });
        }
        #endregion

        #region Invitations Management
        [ApiAuthorize]
        // GET: /api/MyInvitations
        public async Task<string> MyInvitations()
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                return await _JsongAsync(new ObiList<Invitation>
                {
                    StatusCode = HttpStatusCode.OK,
                    List = cuser.Invitations
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/InviteAUser/5?UserId=ASDSADA
        public async Task<string> InviteAUser(int id/*Group Id*/, string UserId)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Groups.FindAsync(id) as Team;
                //Can not find target team.
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //I am not an admin and I am not an owner.
                var MyRelation = Target.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                if (MyRelation == null || (MyRelation.RelationType != GU_RelationType.Owner && MyRelation.RelationType != GU_RelationType.Admin))
                {
                    return ForbiddenResult;
                }
                //Can not fine the User
                if (await UserManager.FindByIdAsync(UserId) == null)
                {
                    return await _JsongAsync(new ServerReply
                    {
                        StatusCode = HttpStatusCode.NotModified
                    });
                }
                //User Already Joined.
                if (Target.GU_Relations.Find(t => t.ObisoftUserId == UserId) != null)
                {
                    return NotAcceptableResult;
                }
                //Create Invitaion
                //DbContext.Invitations.Add(new Invitation
                //{
                //    GroupId = id,
                //    ObisoftUserId = UserId
                //});
                return OkResult;
            });
        }
        #endregion

        #region Privacy Management
        [ApiAuthorize]
        // GET: /api/PrivacyState
        public async Task<string> PrivacyState()
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                var model = new PrivacyStateViewModel(cuser);
                return await _JsongAsync(new ObiObject<PrivacyStateViewModel>
                {
                    StatusCode = HttpStatusCode.OK,
                    Object = model
                });
            });
        }

        [ApiAuthorize]
        // POST: /api/SetPrivacyState
        public async Task<string> SetPrivacyState(PrivacyStateViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                cuser.AllowAddtoMyCalendar = model.AllowAddtoMyCalendar;
                cuser.AllowSeeIfImFree = model.AllowSeeIfImFree;
                cuser.AllowSeeMyCalendar = model.AllowSeeMyCalendar;
                cuser.AllowSeeMySchoolAndAccount = model.AllowSeeMySchoolAndAccount;
                cuser.AllowSeeWhatImDoing = model.AllowSeeWhatImDoing;
                await UserManager.UpdateAsync(cuser);
                return OkResult;
            });
        }
        #endregion

        #region Posts Management
        [ApiAuthorize]
        // GET: /api/PostsCenter?Take=5
        public async Task<string> PostsCenter(int Take)
        {
            return await this._apiReplyTool(async () =>
            {
                var Return = new List<Posts>();
                var cuser = await userAsync();
                //Group
                foreach (var Relation in cuser.GU_Relations)
                {
                    foreach (var Posts in Relation.Group.GroupPostss)
                    {
                        Return.Add(Posts);
                    }
                }
                //Friends
                foreach (var Friend in cuser.AllFriends())
                {
                    Return.AddRange(Friend.PersonalPostss);
                }
                //OrderBy
                return await _JsongAsync(new ObiList<Posts>
                {
                    StatusCode = HttpStatusCode.OK,
                    List = Return.OrderByDescending(t => t.PublishDate).Take(Take)
                });
            });
        }

        [ApiAuthorize]
        // GET: /api/AllPostsFromGroup/5?Take=5
        public async Task<string> AllPostsFromGroup(int? id/*Group Id*/, int Take)
        {
            return await this._apiReplyTool(async () =>
            {
                var Return = new List<Posts>();
                var Group = await DbContext.Groups.FindAsync(id);
                //Not Found The Group
                if (Group == null)
                {
                    return NotFoundResult;
                }
                var MyRelation = Group.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                //Not Authorized
                if (MyRelation == null)
                {
                    return ForbiddenResult;
                }
                //Return
                return await _JsongAsync(new ObiList<Posts>
                {
                    StatusCode = HttpStatusCode.OK,
                    List = Return.OrderByDescending(t => t.PublishDate).Take(Take)
                });
            });
        }

        [ApiAuthorize]
        // GET: /api/AllPostsFromPerson/werw23rkasf23r4?Take=10
        public async Task<string> AllPostsFromPerson(string id/*Obisoft User Id*/, int Take)
        {
            return await this._apiReplyTool(async () =>
            {
                var TargetUser = await UserManager.FindByIdAsync(id);
                //Not Found
                if (TargetUser == null)
                {
                    return NotFoundResult;
                }
                var Relation = TargetUser.AllFriends().Find(t => t.Id == User.Identity.GetUserId());
                //Not Friend
                if (Relation == null)
                {
                    return ForbiddenResult;
                }
                //Result
                var Result = TargetUser.PersonalPostss.Take(Take).ToList();
                return await _JsongAsync(new ObiList<PersonalPosts>
                {
                    List = Result,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/PostAsAGroup/5
        public async Task<string> PostAsAGroup(int? id/*Group Id*/, PostsViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var Group = await DbContext.Groups.FindAsync(id);
                //Not Found The Group
                if (Group == null)
                {
                    return NotFoundResult;
                }
                var MyRelation = Group.GU_Relations.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                //Not Authorized
                if (MyRelation == null || MyRelation.RelationType != GU_RelationType.Owner || MyRelation.RelationType != GU_RelationType.Admin)
                {
                    return ForbiddenResult;
                }
                //Add
                var NewPost = new GroupPosts
                {
                    Content = model.Content,
                    Title = model.Title,
                    GroupId = id ?? 0,
                    PublishDate = DateTime.Now,
                    PublisherFormGroupId = User.Identity.GetUserId()
                };
                DbContext.Posts.Add(NewPost);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = NewPost.PostsId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/PostAsAMe
        public async Task<string> PostAsAMe(PostsViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                //Create
                var NewPost = new PersonalPosts
                {
                    Content = model.Content,
                    Title = model.Title,
                    PublishDate = DateTime.Now,
                    ObisoftUserId = User.Identity.GetUserId()
                };
                //Publish
                DbContext.Posts.Add(NewPost);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = NewPost.PostsId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/EditAGroupPost/5
        public async Task<string> EditAGroupPost(int? id/*PostsId*/, PostsViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var OldPost = DbContext.Posts.Find(id) as GroupPosts;
                //Post Not Found
                if (OldPost == null)
                {
                    return NotFoundResult;
                }
                //Unauthorize
                if (OldPost.PublisherFormGroupId != User.Identity.GetUserId())
                {
                    return ForbiddenResult;
                }
                //Update
                OldPost.Title = model.Title;
                OldPost.Content = model.Content;
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/EditAPersonalPost/5
        public async Task<string> EditAPersonalPost(int? id/*PostsId*/, [System.Web.Http.FromBody]PostsViewModel model)
        {
            return await this._apiReplyTool(async () =>
            {
                var OldPost = DbContext.Posts.Find(id) as PersonalPosts;
                //Post Not Found
                if (OldPost == null)
                {
                    return NotFoundResult;
                }
                //Unauthorize
                if (OldPost.ObisoftUserId != User.Identity.GetUserId())
                {
                    return ForbiddenResult;
                }
                //Update
                OldPost.Title = model.Title;
                OldPost.Content = model.Content;
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        // POST: /api/ResponseToPost/5
        public async Task<string> ResponseToPost(int? id/*PostsId*/, PostResposneType Type)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Posts.FindAsync(id);
                //Not Found
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //Already Responsed!
                if (Target.PostResponses.Exists(t => t.ObisoftUserId == User.Identity.GetUserId()))
                {
                    return ConflictSetResult;
                }
                //Response
                var NewResponse = new PostResponse
                {
                    ObisoftUserId = User.Identity.GetUserId(),
                    PostsId = id ?? 0,
                    PostResposneType = Type
                };
                Target.PostResponses.Add(NewResponse);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = NewResponse.PostResponseId
                }); ;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        public async Task<string> UnResponseToPost(int? id/*PostsId*/)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Posts.FindAsync(id);
                //Not Found
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //Find your Response
                var Response = Target.PostResponses.Find(t => t.ObisoftUserId == User.Identity.GetUserId());
                //Not Responsed!
                if (Response == null)
                {
                    return ConflictSetResult;
                }

                Target.PostResponses.Remove(Response);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [HttpPost]
        [ApiAuthorize]
        public async Task<string> CommetToPost(int? id/*PostsId*/, string Content)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.Posts.FindAsync(id);
                //Not Found
                if (Target == null)
                {
                    return NotFoundResult;
                }
                //Update
                var NewComment = new FirComment
                {
                    ObisoftUserId = User.Identity.GetUserId(),
                    PostsId = id ?? 0,
                    Content = Content,
                    PublishDate = DateTime.Now
                };
                DbContext.FirComments.Add(NewComment);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = NewComment.FirCommentId
                });
            });
        }

        [HttpPost]
        [ApiAuthorize]
        public async Task<string> CommetToCommet(int? id/*FirCommentId*/, string Content)
        {
            return await this._apiReplyTool(async () =>
            {
                var Target = await DbContext.FirComments.FindAsync(id);
                if (Target == null)
                {
                    return NotFoundResult;
                }
                var NewCommet = new SecComment
                {
                    FirCommentId = id ?? 0,
                    ObisoftUserId = User.Identity.GetUserId(),
                    PublishDate = DateTime.Now,
                    Content = Content,
                };
                DbContext.SecComments.Add(NewCommet);
                await DbContext.SaveChangesAsync();
                return await _JsongAsync(new ObiValue<int>
                {
                    StatusCode = HttpStatusCode.OK,
                    Value = NewCommet.SecCommentId
                });
            });
        }

        #endregion

        #region FriendPart Management
        [ApiAuthorize]
        public async Task<string> MyParts()
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                var Result = cuser.FriendsPart.ToList();
                return await _JsongAsync(new ObiList<FriendsPart>
                {
                    List = Result,
                    StatusCode = HttpStatusCode.OK
                });
            });
        }

        [ApiAuthorize]
        [HttpPost]
        public async Task<string> CreatePart(string PartName)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                var NewPart = new FriendsPart
                {
                    PartName = PartName,
                    ParentId = cuser.Id
                };
                cuser.FriendsPart.Add(NewPart);
                await UserManager.UpdateAsync(cuser);
                return OkResult;
            });
        }

        [ApiAuthorize]
        [HttpPost]
        public async Task<string> DeletePart(int Id/*PartId*/)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                var TPart = await DbContext.FriendsParts.FindAsync(Id);
                if (TPart == null)
                {
                    return NotFoundResult;
                }
                if (TPart.ParentId != cuser.Id)
                {
                    return ForbiddenResult;
                }
                DbContext.FriendsParts.Remove(TPart);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }

        [ApiAuthorize]
        [HttpPost]
        public async Task<string> RenamePart(int Id/*PartId*/, string NewPartName)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                var TPart = cuser.FriendsPart.Find(t => t.FriendsPartId == Id);
                if (TPart == null)
                {
                    return NotFoundResult;
                }
                if (TPart.ParentId != cuser.Id)
                {
                    return ForbiddenResult;
                }
                TPart.PartName = NewPartName;
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }
        #endregion

        #region Friends Management

        [ApiAuthorize]
        [HttpPost]
        public async Task<string> RemoveFriend(string id/*FriendId*/)
        {
            return await this._apiReplyTool(async () =>
            {
                var cuser = await userAsync();
                var Target = DbContext.FU_Relation.Where(t => t.FriendId == id).ToList()
                .Find(t => t.Parent.ParentId == User.Identity.GetUserId());
                DbContext.FU_Relation.Remove(Target);
                await DbContext.SaveChangesAsync();
                return OkResult;
            });
        }
        #endregion

        #region WeChat API
        [HttpGet]
        // GET: /api/WeChatVerify
        public async Task<string> WeChatVerify(string signature, string timestamp, string nonce, string echostr)
        {
            if (await Verify(signature, timestamp, nonce))
            {
                Response.Write(echostr);
                Response.End();
            }
            return string.Empty;
        }

        [HttpPost]
        // POST: /api/WeChatVerify
        public async Task<string> WeChatVerify(string signature, string timestamp, string nonce, string echostr, object obj)
        {
            if (await Verify(signature, timestamp, nonce))
            {
                var s = Request.InputStream;
                var Result = await XMLDeserializeObjectAsync<xml>(s);
                var ReturnMessage = new xml
                {
                    Content = await Reply(Result.Content),
                    CreateTime = ConvertDateTimeInt(DateTime.Now),
                    ToUserName = Result.FromUserName,
                    FromUserName = Result.ToUserName,
                    MsgType = "text"
                };
                Response.Write(await XMLSerializeObjectAsync(ReturnMessage));
            }
            return string.Empty;
        }

        // GET: /api/AccessTokenTest
        public async Task<string> AccessTokenTest()
        {
            return await this._apiReplyTool(async () =>
            {
                return await AccessTokenAsync();
            });
        }

        // GET: /api/ApplyMenu
        public async Task<string> ApplyMenu()
        {
            return await this._apiReplyTool(async () =>
            {
                var Buttons = new Source
                {
                    button = new List<Button>(1)
                };
                var NewButton = new Button
                {
                    name = "HelloWorld1",
                    sub_button = new List<SubButton>(1)
                };
                NewButton.sub_button.Add(new SubButton
                {
                    name = "Hi",
                    type = "view",
                    url = await GenerateAuthUrlAsync($"https://{Request.Url.Authority}/api/AuthRedirect")
                });
                Buttons.button.Add(NewButton);
                return await _JsongAsync(Buttons);
            });
        }

        // GET: /api/AuthRedirect
        public async Task<ActionResult> AuthRedirect(string code, string state)
        {
            var Result = await AuthCodeToAccessTokenAsync(code);
            var WCUser = await UserInfomationAsync(Result.openid, await AccessTokenAsync());
            var LCuser = UserManager.Users.ToList().Find(t => t.openid == Result.openid);
            if (LCuser == null || LCuser.SchoolAccountSet == false)
            {
                return RedirectToAction("Bind", "WeChat", new { openid = Result.openid });//await Check(WCUser);
            }
            switch (state.ToLower().Trim())
            {
                case "checkmorning":
                    return RedirectToAction("CheckMorning", "WeChat", new { openid = Result.openid });//await Check(WCUser);
                case "schedule":
                    return RedirectToAction("Schedule", "WeChat", new { openid = Result.openid });//await Check(WCUser);
                case "grade":
                    return RedirectToAction("Grade", "WeChat", new { openid = Result.openid });//await Check(WCUser);
            }
            return null;
        }
        #endregion

        #region Other Service API
        public async Task<string> YooleeQueryPeccancy(string city, string carnum, string enginenum, string vin)
        {
            return await this._apiReplyTool(async () =>
            {
                var Result = await OtherService.QueryPeccancy(city, carnum, enginenum, vin);
                if (Result.status == 0)
                {
                    return await _JsongAsync(Result.data?.lists);
                }
                else if (Result.status == -22)
                {
                    return NotFoundResult;
                }
                else if (Result.status == -11)
                {
                    return NotAcceptableResult;
                }
                else
                {
                    return ErrorResult;
                }
            });
        }
        public async Task<string> YooleeQueryInsurance(int CarPrice, int CarYears = 2016)
        {
            return await this._apiReplyTool(async () =>
            {
                var Result = await OtherService.QueryInsurance(CarPrice, CarYears);
                return await _JsongAsync(Result);
            });
        }

        #endregion
    }
}


text:
Any Price (11) Under $100 (5) $100-499 (5) $500-4,999 (1)
author: St John
GOGARTY, Oliver St. John
Going Native.
New York. Duell, Sloan & Pearce. 1940. F. Hardcover. 20cm, first edition, 294p., dark blue cloth, gilt spine and cover titles, a fine copy (ihds).
I Follow Saint Patrick. Illustrated by Bip Pares.
London. Rich & Cowan. 1938. 1938. 1st Edition. Hardcover. 21.5cm, first edition, 336p., with 4 maps (1 folding), 7 plates (1 double page), illustrated endpapers, index, blue cloth with white titles, a very good copy (Ilds) Follows the journeys of St. Patrick as far as they are traceable." Preface.
JOYCE, Weston, St. John.
The Neighbourhood of Dublin, its Topography, Antiquities and Historical Associations. With numerous illustrations from the Author's Photographs & Sketches and an Introduction by P.W. Joyce.
Dublin. M.H. Gill & Son. 1921. Hardcover. 8vo, 21.5cm, 2nd Edition Enlarged, xx,512p., frontis & 130 plates and illustrations (inc. 1 folded plate & 2 folded maps), index, original green cloth, gilt spine titles, stylized presentation inscription on the front free fly, a few small fade speckles towards to fore.....
PHILBY, Harry St. John
Autograph Letter Signed. One page, hand written, on letter head, The Athenaeum, Pall Mall S.W.I.
Dated July 30, 1941. 20x 12cm, folded, with stamped hand-written envelop, dated July 30, 1941., in fine condition. (Cgc.bx) From English Arabist and explorer, H.J.B. Philby, to J.L. Steele, Russell, Ontario, Canada. ". have been away in Arabia during the first part of the war . Mesopotage (sic ?) was.....
SEYMOUR, St. John & Harry L. Neligan. (compiled by).
True Irish Ghost Stories.
Syracuse. Castle. 1974. Hardcover. 8vo. 23cm, xxiii,274p., green boards, gilt titles, fine in fine jacket (s9.8). The first major collection of true Irish short stories compiled entirely from accounts sent in by correspondents from all over Ireland. First published in 1914.
ST JOHN, Charles
Wild Sports and Natural History of the Highlands. With an Introduction and Notes by Rt. Hon. Sir Herbert Maxwell.
London. Gurney and Jackson. 1927. 1st Edition. Hardcover. 23cm, first edition, xxx,472p., colour frontis, 38 plates (28 colour), 22 text illustrations, index, dark green cloth, gilt spine titles, hinges re inforced with binder tape, else fine (sc) A naturalist sportsman writes of the Scottish Highlands, in particular Morayshire. With vivid.....
ST. JOHN, J. Bascom
Separate Schools in Ontario. Reprinted from The Globe and mail, Canada's National Newspaper.
(Toronto). The Globeand Mail. 1963. Soft cover. 20.5cm, 40p., portrait of author, bibliography,illustrated wraps, fine. (eds). - An attempt to explain the origin andhistory of the Ontario Separate School system. Put out in response torequests for legislative action concerning the schools by the RomanCatholic Bishops of Ontario in 1962.
ST. JOHN, James Augustus
Life of Sir Walter Raleigh. 1552-1618.
London. Chapman and Hall. 1869. Hardcover. 12mo. 20cm, second edition, x,481p., original brown cloth, gilt spine titles and decoration, fine (tgc) One of the early biographies of Sir Walter Raleigh by the well-known nineteenth century British author noted for his travel and political writings. Originally published in 1868.
ST. JOHN, Judith
The Osborne Collection of Early Children's Books, 1476-1910. A Catalogue. With Introduction by Edgar Osborne. In Two Volumes.
Toronto. Toronto Public Library. 1975. Tall8vo, 25cm, in 2 volumes, xxiiiv,562 & xii,563-1138pp., many plates and illustrations, appendix, chronology, indexes, quarter darker green cloth backed illustrated green cloth boards, gilt spine titles, near fine. (bks). Third issue with additonal corrections.
ST. JOHN].
Souvenir of the Queen's Jubilee. An Account of the City of Saint John, New Brunswick, in Honour of the Jubilee Year of the Reign of Her Most Gracious Majesty, Queen Victoria.
Saint John, N.B. J.&A. McMillan. 1887. Soft cover. 19.5cm, iii,97p., brown decorated printed wraps, spine edges bit frayed, else very good to fine. (Atl) A detailed program of the events, from June 19th to 21st 1887, in celebration of the fiftieth year of Queen Victoria's reign. Includes a complete membership.....
ST.JOHN, Judith
Where the Saints have Trod. Illustrated by Robin Jacques.
London. Oxford University Press. 1974. F. Hardcover. 21.5cm, the first edition, xi,107p., yellow cloth, a fine copy in near fine price clipped jacket (S4.4).

redpajama_set_name: RedPajamaCommonCrawl


text:
Authentic Vibes Only
There! I fixed it!
I totally understand what this is trying to do. It's trying to remind us to focus on the positive things in life, to take stock of what we're grateful for, and to choose not to let the negative things rule our lives. But "Good Vibes Only" (and other sentiments like it) is often used to shut down and ignore the harder feelings of life.
Imagine how it might read, for instance, to a person in a season of deep grief: "If only good vibes are welcome here, *I'm* not welcome here."
Let's remember that our authentic vibes are always better than the ones we fake. So, if you're full of positivity today, you're welcome here. If you're full of doubt and frustration today, you're welcome here. If you're full of grief and sadness, you're welcome here. And if you're somewhere in between, you're welcome here!


text:
Housing Authority of the City of Bayonne v. Hanna
Opinion Date: November 21, 2011
EVICTION; HOUSING AUTHORITY — Just because a jury finds that a public housing tenant fraudulently concealed or misrepresented an ownership interest in other property, such a verdict does not automatically entitle the housing authority to damages or give it the right to evict the tenant.
A tenant loaned his brother money to purchase property. The tenant's name was placed on the deed to ensure payment. Once his brother paid in full, they executed a contract of sale to transfer the property. The brothers met with an attorney to prepare a deed transferring the tenant's interest to his brother and they both believed the tenant's name had been removed from the deed. However the attorney unexpectedly died without filing a new deed.
The tenant then submitted an application to the municipality's Housing Authority for low income public housing, stating he had no assets and owned no real property. The lease allowed the housing authority to evict a tenant if he or she made a misrepresentation of any material fact in an application for housing or in a statement submitted to the housing authority. After receiving an anonymous tip that the tenant owned the property where he resided, the housing authority told the tenant that his ownership interest rendered him ineligible for public housing, and it would seek to terminate his lease due to his misrepresentation of ownership. Ultimately, the housing authority filed an eviction complaint, seeking a judgment of possession and sought damages. At trial, the jury was instructed on the elements of fraud and damages. The lower court also used a verdict sheet. The jury answered "yes" to whether the housing authority had proven that the tenant fraudulently concealed or misrepresented his ownership interest in the property, however it answered "no" to whether the housing authority should recover monetary damages and compensatory damages. The lower court entered a judgment of no cause and dismissed the complaint with prejudice.
The housing authority appealed, arguing that the verdict was inconsistent and that the jury's finding that the tenant had committed fraud entitled it to possession and damages. The Appellate Division concluded that while the jury did, in fact, find that the housing authority had proven, by clear and convincing evidence, that tenant fraudulently concealed or misrepresented his ownership interest in the property, this verdict did not automatically entitle the housing authority to damages or eviction. The jury then found either that the housing authority suffered no damages, or failed to meet its burden of proof for damages and eviction. Accordingly, the Court found nothing inconsistent in the jury's verdict, and affirmed the dismissal.


The state of Arizona has some of the most stringent drug laws and regulations in the country. Although the use of medical marijuana is allowed, the state still maintains several regulations regarding the appropriate use of marijuana for this purpose. Understanding current marijuana regulations in Arizona allows you to separate myth from fact and protect your rights and your reputation.
While Arizona allows for the legal use of medical marijuana, there are still several limitations associated with the state's medical marijuana laws. As of 2012, it is illegal to possess marijuana for any reason on a college campus, including medical purposes. Furthermore, a 2014 ruling maintained that medical marijuana use does not provide drivers with immunity if they are pulled over and test positive for marijuana. While medical marijuana cardholders can be fired if in possession or under the influence of marijuana while in the workplace, employers cannot take negative action against an employee for their cardholder status alone.
Without a medical marijuana card or license, the possession, sale, and manufacture or cultivation of marijuana is considered a state felony. The penalties for these crimes are based on the amount of marijuana found, with distinctions made for quantities of less than two pounds of marijuana, four pounds or more of marijuana, and between two and four pounds of marijuana. Individuals who are found with marijuana may face jail sentences of four months to 12.5 years and fines of up to $150,000. Factors such as employing a minor in a drug-related offense, past convictions, and drug offenses committed within school zones can all lead to increased jail time upon a successful conviction.
If you are facing a felony marijuana charge, you need the experienced help of a professional defense attorney serving Tucson. Steven D. West, P.C. is proud to provide skilled representation for both state and federal offenses, including drug and marijuana charges. Please visit our website or call our legal practice today at (520) 623-4387 to learn more.


The Android Support Package is a set of static libraries with additional APIs that can be used by an application. These libraries back port some newer APIs to older versions of Android. At the current time, there are two versions of the Support Package.
The v4 Support Package is designed to bring Fragment and other support to Android 1.6 (API Level 4) and later. If a program needs to use some new features and run on Android 2.2, this is the library that it needs to use. Our sample application will use the v4 Support Package.
The v13 Support Package is similar in concept to the v4 Support Package. This package requires Android 3.2 (API Level 13) or later. It has some underlying implementation changes.
There's a multi-step process in setting up an application to use the Android Support Package. To get a project setup to use the v4 Support Package, complete the following steps.
First, download the Android Support Library in the Android SDK, as shown in Figure 1.
Figure 1. Install the Android Support Library package in the Android SDK.
Next, create an Android Application in Visual Studio (or MonoDevelop). In the project settings of the project, set the Minimum Android to target value to Android 1.6 (or a later version) as shown in Figure 2.
Figure 2. Set the Minimum Android to target value to Android 1.6.
Then add a reference in the project to Mono.Android.Support.v4, as shown in Figure 3.
Figure 3. Add a reference to Mono.Android.Support.v4.
The next step is to add in the Android-Support-v4.jar. The library is located in the extras directory of the Android SDK. Place this library into the directory called "SupportLib" in the project, and change its Build Action to AndroidJavaLibrary.
Activity. An Android application that hosts Fragments must inherit from Android.App.FragmentActivity. Previously, an Activity would inherit from Android.App.Activity.
Namespaces. Classes that previously inherited from Android.App.Fragment must now inherit from Android.Support.v4.Fragment.
FragmentManager. With Android.App.Activity, there's a FragmentManager property. The Android.App.FragmentActivity provides the SupportingFragmentManager property. This property is used to obtain a reference to the FragmentManager.
Aside from these differences, the APIs are fairly consistent. Now, let's move to some code.
Small. A small screen is up to approximately 3.7 inches diagonal.
Normal. A normal screen is between approximately 3.5 and 4.5 inches diagonal.
Large. A large screen is between approximately 4.1 and 7 inches diagonal.
XLarge. An extra large screen is approximately 7 inches diagonal and up.
Android uses the screen size of the device and the density of the display to determine the appropriate layout resource to display within the application. A discussion of building a device independent screen layout is beyond the scope of this article; however, it's important to understand the basics. For this application, notice that there are two directories containing layouts. One is the Layout directory, which contains the layout files used for a handset display. The Layout-large directory contains the layout files for a larger device, in this case a tablet.
Let's take a look at the Main Layouts for a handset. In the following code, the TitlesFragment is loaded. The Fragment is the Fragment defined in the TitlesFragment.cs file.
The Main Layout for a tablet is shown in Listing 2. The Fragment defined in the TitlesFragment.cs file is loaded first, and then a FrameLayout is loaded. In this project, the android:layout_weight attribute defines the relative width of each element. The TitlesFragment and the FrameLayout each display on 50 percent of the screen.
The TitlesFragment.cs file, shown in Listing 3, inherits from the Android.Support.V4.App.ListFragment class. This class is analogous to the ListFragment class available as a "regular fragment." The OnActivityCreated method that the class overrides is in charge of loading the appropriate user interface. The FragmentManager is exposed via Android.Support.V4.App.ListFragment class. This is different from the SupportingFragmentManager that is exposed via the FragmentActivity class.
The DetailsActivity.cs file, shown in Listing 4, is loaded when a user selects a Star Trek character and displays a picture and a quote. This code uses the SupportFragmentManager property of the FragmentActivity class. It loads the DetailsFragment. The OnCreate method creates an instance of the DetailsFragment, and then loads it via the FragmentManager that's exposed via the support libraries.
The DetailsFragment class, shown in Listing 5, inherits from Android.App.V4.App.Fragment class, which allows access to the fragment functionality.
The OnCreateView is used to create the necessary user interface. Notice that the user interface is created programmatically. The user interface could just as easily have been created by loading a layout file and then filling the values that way.
Now that the code has been examined, let's look at the output of the application. The list of Star Trek characters and detail view running in an Android 2.3.3 emulator are shown in Figures 4 and 5.
Figure 4. List of Star Trek characters running on an Android 2.3.3 emulator.
Figure 5. Detail view of a Star Trek character taken from an Android 2.3.3 emulator.
The list of Star Trek characters and detail view running in an Android 4.0.3 emulator are shown in Figures 6 and 7.
Figure 6. List of Star Trek characters running on an Android 4.0.3 emulator.
Figure 7. Detail view of a Star Trek character taken from an Android 4.0.3 emulator.
Notice that the only variance between the two displays is the slight difference in the way that the respective emulators are setup.
Finally, what happens when the application runs on a tablet device? Figure 8 shows the output of the Star Trek application in an Android 4.0.3 tablet emulator.
Figure 8. Application running in an Android 4.0.3 tablet emulator.
It's possible to write an application that runs on Android handsets, tablets, Android 2.x, 4.x, and to take advantage of many of the features on these platforms. Fragmentation? When people talk about fragmentation of the Android platform, I can't help but wonder what they are talking about. After a little setup, Mono for Android can give you full support for the Android Support Package. The APIs are nearly the same between the Support Library and the most recent Android releases for Fragments.


Happy New Years, Everyone. The first weekend of the year has come & gone and I am already energized by the next 51, including all the weekdays in between. While many people are focused on losing weight, baggage, debt, etc – I will fixate my efforts on GAINING. I spent the holidays having very restricted interaction with social media and the internet, spending that time self-reflecting. Most of it was used reading running magazines (trying to convince myself I can actually like it), listening to TED Talks, and being physically active. My biggest take away was that we, by nature, use our energy to fix whatever is negative. But what if…If we put our attempts in enhancing the positives to gain what we want in our lives?
Gaining the confidence to do all the crazy things you want to do and having no clue how to get there. Just continue putting one foot in front of the other until you reach your destination. Over the last 38 years, I have accepted things about myself to realize I have pretty great things going for me already. Even when I was at my lowest, I still found some light at the end of the tunnel. Search for your awesome qualities and build on those to do the things you thought you never could do.


By Andrew Bainbridge of The Bainbridge Firm, LLC posted in Workers' Compensation on Monday, March 4, 2019.
If you've ever performed a job that required you to repeat the same motion over and over again, then you may not have realized that you could have seriously damaged your muscles and connective tissue in the process. Called repetitive motion injuries, the damage associated with such injuries can take a long time before symptoms present themselves. But in some cases, when symptoms -- such as pain or numbness -- do present themselves, it may be too late to fully correct the damage.
By Andrew Bainbridge of The Bainbridge Firm, LLC posted in Workers' Compensation on Thursday, May 10, 2018.
The Centers for Disease Control and prevent reported that more than 9 percent of nonfatal workplace injuries and illnesses in 2009 were sustained by construction workers. That year, construction workers suffered 4.3 nonfatal injuries and illnesses per 100 workers.
Can I be compensated for sustaining an injury on my way to a medical exam ordered by the BWC?
By Kara Dolan of The Bainbridge Firm, LLC posted in Medical Care Benefits on Friday, April 3, 2015.
A Court of Appeals has held that injuries sustained by the claimant while traveling to or from a Bureau medical examination are compensable "as being directly and proximately caused by circumstances that arose out of employment as the original injuries and obligations necessitated by those injuries in order to participate in the Workers' compensation fund, directly resulted in the new injuries."
Is an injury compensable if the employee was engaging in recreational or social activity during the time of the injury?
By Kara Dolan of The Bainbridge Firm, LLC posted in Workplace Accidents and Injuries on Friday, January 2, 2015.
The type of activities conducted on the employment premises is often determinative of the course of employment issue. Injuries sustained during recreational and social activities on the employer's premises have generally been held to be compensable. However, to be compensable, the injury must have been sustained while engaging in activities that were customary, either in the industry or in the particular place, in order for the activities to qualify as a regular incident of employment.
Am I Eligible for Benefits If I Was Performing A Public Service?
By Kara Dolan of The Bainbridge Firm, LLC posted in General Information on Friday, August 22, 2014.
The Ohio Revised Code extends workers' compensation coverage to persons requested or ordered to perform public service in an emergency. The section does not include persons who are volunteers, and application of the code is expressly limited to emergency situations. A duly authorized public official of the state, one of its institutions or agencies, or a political subdivision, can request or order the public service. The statutorily expressed purpose is to encourage participation of all appropriate persons in an emergency.


Check out this deal for Father's Day! Help dad go retro with these fun shoes!
Save 51% on the Men's Lifestyle 574 now just $41.99(discount applies automatically at checkout) only at JoesNewBalanceOutlet.com! Offer ends 6/11.


Watches have almost transformed themselves into time keepers into classy accessories over the years. With smartphones and technology surrounding us everywhere, it's almost impossible not to know the time and day of the week, even without a watch. If you are a stylish business woman or just want to dress up your outfit a bit, an elegant watch is the perfect accessory to add to your ensemble. Women's watches in Cairo are dainty, sophisticated, and chic and offer an incredibly wide selection for everyone's personal style.
With colors ranging from pink to black available in stores from well-known designers such as Michael Kors and Gucci , it's not surprising that there is such a wide price range of women's watches. For more elegant occasions or a special night out, Diamond watches are also available if you're able to spend a bit more money. Help narrow down your choices by filtering watches by designers, colors, and prices without convenient and easy to use filtering system. After you have chosen the perfect watch, it is then easy to view the stores it is sold by and choose the best price.
The Women Watches category on pricena has more than 3071 products and 110 brands ,sold by 8 Stores. The prices of Women Watches in Egypt range from EGP 22 to EGP 262464. The most popular brands are Casio, Swatch, Alba, Lee Cooper, Esprit. You can refine the search results of Women Watches products by using advanced filters by brand, price range, store, Watch Shape, Strap Material, Watch Type, Watch Movement, Watch Size.. The most popular Women Watches products on pricena are Casio LTP-V004G-9B Stainless Steel Watch, Swatch Wiafa Women's Gold Dial, Swatch Women's Silver Dial Stainless, Casio LA670WA-1DF Digital Watch in, Esprit ES108152006 For Women analog. By comparing prices before you buy, you can achieve Average savings in this category of EGP 282 and up to EGP 999.


text:
package io.termd.core.http.netty;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import io.termd.core.tty.TtyConnection;

import java.util.function.Consumer;

/**
 * @author Julien Viet
 */
public class TtyServerInitializer extends ChannelInitializer<SocketChannel> {

  private final ChannelGroup group;
  private final Consumer<TtyConnection> handler;

  public TtyServerInitializer(ChannelGroup group, Consumer<TtyConnection> handler) {
    this.group = group;
    this.handler = handler;
  }

  @Override
  protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(new HttpServerCodec());
    pipeline.addLast(new ChunkedWriteHandler());
    pipeline.addLast(new HttpObjectAggregator(64 * 1024));
    pipeline.addLast(new HttpRequestHandler("/ws"));
    pipeline.addLast(new WebSocketServerProtocolHandler("/ws"));
    pipeline.addLast(new TtyWebSocketFrameHandler(group, handler));
  }
}

redpajama_set_name: RedPajamaGithub


text:
Human Genetics & Evolution
Auto Workers Issues
Nationalism and the union bureaucracy
Workers Struggles Around the World
Workers Issues in Canada
Workers Issues in the US
European Workers Issues
Workers Issues in Australia & the Pacific
As the coronavirus tolls soar worldwide
Deaths from COVID-19 in New York double in three days
By Bryan Dyne
The number of deaths caused by COVID-19 in New York state has doubled in the past three days, from 1,550 to more than 3,200, with more than 102,000 cases statewide. New York City alone accounts for about half of these, with 1,600 dead and 57,000 cases. The country as a whole now has, as of this writing, 277,161 cases and 7,392 deaths, including a record 32,284 new cases yesterday and 1,321 deaths.
New York is the epicenter of the coronavirus pandemic in the United States and is rapidly becoming the epicenter of the pandemic worldwide. There are now just under 1.1 million confirmed cases of the disease internationally, and less than a quarter have so far recovered. An estimated 4 billion people around the world are under some form of stay-at-home order. To date, more than 56,000 men, women and children of all ages have died, placing the current average fatality rate at 5.4 percent.
Other countries with surging coronavirus cases include:
Italy: 119,827 cases and 14,681 deaths
Spain: 119,199 cases and 11,198 deaths
Germany: 91,159 cases and 1,275 deaths
France: 64,338 cases and 6,507 deaths
Iran: 53,183 cases and 3,294 deaths
Britain: 36,168 cases and 3,605 deaths
Turkey: 20,921 cases and 425 deaths
This was the context in which President Donald Trump gave yet another press conference on Friday combining self-praise, bullying of the press, stonewalling and outright lies. In prepared remarks, Surgeon General Jerome Adams stated that, "We now know that a significant portion of individuals with coronavirus lack symptoms," and that they "can transmit the virus to others before they show symptoms."
What blatant falsifications! Health experts in China and the World Health Organization (WHO) warned in January that the novel coronavirus was spreading so fast because those who were contagious often did not show symptoms for up to 14 days. It is the primary reason that the WHO has for months stressed the need to "test, test, test" for the virus. The US itself recognized this fact in January when it began two-week quarantine periods for all people traveling from Wuhan, the first epicenter of the pandemic.
Trump again displayed his criminal indifference to the suffering of hundreds of thousands of people who are infected in the country, summed up in his response to a question about appeals from states and municipalities for desperately needed medical equipment. "We're not a shipping clerk," he snapped.
At the same time, he casually mentioned that the various oil executives with whom he had met earlier in the day, multimillionaires all, "were all given the [coronavirus] test before they came into the room." Trump himself "had the test yesterday." He seemed oblivious to the reality of millions of ordinary Americans, including those with symptoms, being denied testing, while the wealthy and well-connected have no problem getting access to the test.
He once again absolved himself of any responsibility for the dearth of masks, protective gear, ventilators and other critical medical supplies, blaming the Obama administration. After Health and Human Services Secretary Alex Azar, a former pharmaceutical executive and lobbyist, asserted, falsely, "For fifteen years now, this country has had a massive effort at the federal, state and local level of preparedness for a pandemic," Trump gave no indication why lifesaving equipment needed to fight a pandemic was not available. He silenced a reporter by stating, "You should speak to the previous administration, because the shelves were empty."
Trump blamed New York for its lack of ventilators, declaring, "They should've had more ventilators at the time." Despite warnings from Governor Andrew Cuomo and New York City Mayor Bill de Blasio that they will be unable to care for new critical patients next week, Trump said, "We happen to think that [Cuomo] is well-served with ventilators."
In the meantime, Trump's much ballyhooed deployment of field and naval hospitals to New York City has proven to be a cruel deception. The hospital ship Comfort, which has been docked in the city's harbor for a week, has only taken on a mere 20 out of a potential 1,000 patients.
Deborah Birx, the Coronavirus Task Force response coordinator, continued the whitewashing efforts by declaring that only "when we get through this" could there be any "questions about could we have done some piece of this better."
This is a bipartisan position. House Speaker Nancy Pelosi announced Thursday that she was establishing a bipartisan committee to monitor the federal response to the COVID-19 crisis. But she stressed that its mandate would be to oversee the "here and now" and not be "retrospective," i.e., that the Democrats would oppose any serious investigation into the criminally negligent response of the government to the virus.
No mention was made by any member of the political establishment or media of the workers who are dying after being forced to stay on the job without adequate protective equipment. Five workers at Ford and eight at Fiat Chrysler have so far died after being exposed to the virus at work. Instacart, Amazon and Whole Foods workers have walked out to demand that the corporations—the latter two owned by multibillionaire Jeff Bezos—ensure that their employees are protected from the ravages of the disease.
While New York is the most seriously hit, many other regions in the country are facing a similarly catastrophic situation. New Jersey, Michigan, California, Massachusetts, Louisiana and Florida all have at least 10,000 cases and at least 170 deaths. Cities such as Chicago, Detroit, Seattle and New Orleans are particularly inundated. Their health care systems are likely a week behind the breakdown taking place in New York City.
One of the many reasons these and other areas are unable to cope with the crisis is the pervasive and massive price gouging on basic medical supplies. Gloves are often four times the regular price, while masks are marked up as much as 15 times. Hospitals in upstate New York owned by Arnot Health report that Blank Industries has tried to force them to buy N95 respirator masks for $4.92 each, and only if they order one million at a time. Such large orders of masks before the pandemic would have cost less than $50,000.
Such chaos and criminality are hallmarks of capitalism, which puts profit before human life.
With each passing day, it becomes ever clearer that the American ruling class has no intention of taking any measures that will prevent the pandemic from claiming hundreds of thousands and potentially millions of lives. Rather, all of the efforts of the entire political establishment and both corporate-controlled parties are devoted to protecting and even increasing the wealth of the financial oligarchy, as seen in the $6 trillion corporate bailout package passed last week with virtually unanimous support from both Democrats and Republicans—including Vermont Senator Bernie Sanders.
Meanwhile, the jobs of millions of workers are being wiped out in what is rapidly developing into the deepest economic slump since the Great Depression.
The vital social resources needed to contain this pandemic and care for those infected must be seized by the working class from the capitalist owners and transformed into public utilities under the democratic control of the working people, as part of a centrally planned socialist economy based on the satisfaction of social needs, not private profit.
The working class, socialism and the fight against the pandemic
[1 April 2020]
No corporate bailouts! Direct financial resources to the working people, not the capitalist elite!
[23 March 2020]
Inside the COVID-19 outbreak at Lakepointe nursing home in Clinton Township, Michigan
Biden "recovery" plan will fail to relieve social misery or stop pandemic death
US government executes intellectually disabled death row prisoner Corey Johnson
The coronavirus pandemic
Irish health system on brink of collapse as COVID-19 figures surge
CAMI autoworkers should reject Unifor's attempt to reopen contract with GM Canada!
999 How the working class can intervene to stop Trump's coup plotting (13/01/2021)
About the WSWS | Contact Us | Privacy Statement | wsws.footer.settings | Top of page