Beispiel #1
0
        public ActionResult Edit(int id, Leadership leadership, HttpPostedFileBase uploadImage)
        {
            if (id == leadership.Id)
            {
                if (leadership.Photo == null)
                {
                    if (uploadImage != null)
                    {
                        byte[] imageData = null;
                        using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                        {
                            imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                        }
                        leadership.Photo = imageData;
                    }
                    else
                    {
                        leadership.Photo = null;
                    }
                }

                db.Entry(leadership).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        //Отображение описания руководителя для пользователей
        public ActionResult UserLeadershipDescription(int id)
        {
            Leadership Leadership = db.Leaderships.Find(id);

            ViewBag.Leadership = Leadership;
            return(View());
        }
Beispiel #3
0
        public ActionResult Edit(int id)
        {
            Leadership EditLeadership = db.Leaderships.Find(id);

            ViewBag.EditLeadership = EditLeadership;
            return(View());
        }
Beispiel #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Leadership leadership = db.Leaderships.Find(id);

            db.Leaderships.Remove(leadership);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private static void enumerating2()
        {
            Leadership leadership = new Leadership("Brighton", "Msuya", "Hadji", "Kibinda");

            foreach (string leader in leadership)
            {
                Console.WriteLine(leader);
            }
        }
Beispiel #6
0
 public ActionResult Edit(Leadership leadership)
 {
     if (ModelState.IsValid)
     {
         db.Entry(leadership).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(leadership));
 }
Beispiel #7
0
        //
        // GET: /Leaderships/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Leadership leadership = db.Leaderships.Find(id);

            if (leadership == null)
            {
                return(HttpNotFound());
            }
            return(View(leadership));
        }
Beispiel #8
0
        public ActionResult Delete(int id)
        {
            Leadership leadership = db.Leaderships.Find(id);

            if (leadership != null)
            {
                db.Leaderships.Remove(leadership);
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Beispiel #9
0
        public ActionResult Create(Leadership leadership)
        {
            if (ModelState.IsValid)
            {
                db.Leaderships.Add(leadership);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(leadership));
        }
Beispiel #10
0
        public ActionResult Declaration(int LeadershipId)
        {
            //int LeadershipId = Convert.ToInt32((TempData.Peek("leaderid") as string));
            Leadership leader = db.Leaderships.Find(LeadershipId);

            string filename    = Server.MapPath(leader.LeadershipDeclaration);
            string contentType = "application/pdf";

            //string DownLoadName=leader.LeadershipName.ToString();


            return(File(filename, contentType));
        }
Beispiel #11
0
 public ActionResult Add(Leadership leadership, HttpPostedFileBase upload)
 {
     leadership.Description = leadership.Description;
     if (upload != null)
     {
         byte[] imageData = null;
         using (var binaryReader = new BinaryReader(upload.InputStream))
         {
             imageData = binaryReader.ReadBytes(upload.ContentLength);
         }
         leadership.Photo = imageData;
     }
     db.Leaderships.Add(leadership);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public Leadership Details(int LeaderID)
        {
            Leadership ET = new Leadership();

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[config].[uspReadLeadership]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                //Insert Parameters
                SqlParameter pMinistryID = new SqlParameter
                {
                    ParameterName = "@LeaderID",
                    SqlDbType     = SqlDbType.Int,
                    Value         = LeaderID
                };
                SqlCmd.Parameters.Add(pMinistryID);

                using (var dr = SqlCmd.ExecuteReader())
                {
                    dr.Read();
                    if (dr.HasRows)
                    {
                        ET.LeaderID    = Convert.ToInt32(dr["LeaderID"]);
                        ET.FullName    = dr["FullName"].ToString();
                        ET.Description = dr["Description"].ToString();
                        ET.ImagePath   = dr["ImagePath"].ToString();
                        ET.ActionLink  = dr["ActionLink"].ToString();
                        ET.Order       = Convert.ToInt32(dr["Order"]);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }
            return(ET);
        }
Beispiel #13
0
        public HttpResponseMessage AddNew([FromBody] Leadership model)
        {
            var authHeader = this.Request.Headers.GetValues("Authorization").FirstOrDefault();
            var token      = authHeader.Substring("Bearer ".Length);
            var handler    = new JwtSecurityTokenHandler();
            var jsonToken  = handler.ReadToken(token);
            var tokenS     = handler.ReadToken(token) as JwtSecurityToken;

            var UserName = tokenS.Claims.First(claim => claim.Type == "UserName").Value;

            var r = LBL.AddNew(model, UserName);

            if (!r)
            {
                return(this.Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, r));
            }
        }
        public List <Leadership> List()
        {
            List <Leadership> List = new List <Leadership>();

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[config].[uspReadLeadership]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                using (var dr = SqlCmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var detail = new Leadership
                        {
                            LeaderID    = Convert.ToInt32(dr["LeaderID"]),
                            FullName    = dr["FullName"].ToString(),
                            Description = dr["Description"].ToString(),
                            ImagePath   = dr["ImagePath"].ToString(),
                            Order       = Convert.ToInt32(dr["Order"]),
                            ActionLink  = dr["ActionLink"].ToString()
                        };
                        List.Add(detail);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }
            return(List);
        }
Beispiel #15
0
 public void UpdateLeadership(Leadership leadership)
 {
     _context.Entry(leadership).State = EntityState.Modified;
 }
Beispiel #16
0
 public void InsertLeadership(Leadership leadership)
 {
     _context.Leaderships.Add(leadership);
 }
        public Leadership GenerateLeadership(int level, int charismaBonus, string leaderAnimal)
        {
            var leadership = new Leadership();
            leadership.Score = level + charismaBonus;

            var leadershipModifiers = new List<string>();
            var reputation = percentileSelector.SelectFrom(TableNameConstants.Set.Percentile.Reputation);
            var leadershipAdjustments = adjustmentsSelector.SelectFrom(TableNameConstants.Set.Adjustments.LeadershipModifiers);

            if (string.IsNullOrEmpty(reputation) == false)
            {
                leadershipModifiers.Add(reputation);
                leadership.Score += leadershipAdjustments[reputation];
            }

            leadership.CohortScore = leadership.Score;
            var cohortDeaths = 0;

            while (booleanPercentileSelector.SelectFrom(TableNameConstants.Set.TrueOrFalse.KilledCohort))
                cohortDeaths++;

            leadership.CohortScore -= cohortDeaths * 2;

            if (cohortDeaths > 0)
            {
                var modifier = string.Format("Caused the death of {0} cohort(s)", cohortDeaths);
                leadershipModifiers.Add(modifier);
            }

            if (string.IsNullOrEmpty(leaderAnimal) == false)
                leadership.CohortScore -= 2;

            var followerScore = leadership.Score;
            var leaderMovement = percentileSelector.SelectFrom(TableNameConstants.Set.Percentile.LeadershipMovement);

            if (string.IsNullOrEmpty(leaderMovement) == false)
            {
                leadershipModifiers.Add(leaderMovement);
                followerScore += leadershipAdjustments[leaderMovement];
            }

            if (booleanPercentileSelector.SelectFrom(TableNameConstants.Set.TrueOrFalse.KilledFollowers))
            {
                leadershipModifiers.Add("Caused the death of followers");
                followerScore--;
            }

            leadership.LeadershipModifiers = leadershipModifiers;
            leadership.FollowerQuantities = leadershipSelector.SelectFollowerQuantitiesFor(followerScore);

            return leadership;
        }
 public bool AddNew(Leadership Leader, string insertuser)
 {
     return(LDAL.AddNew(Leader, insertuser));
 }
 public bool Update(Leadership Leader, string insertuser)
 {
     return(LDAL.Update(Leader, insertuser));
 }
 public static string GetPlayerLeadershipName(Leadership leadership)
 {
     return (HM.Resources.Constants.EnumNames.PlayerLeadershipNames[(int)leadership]);
 }
        public bool AddNew(Leadership Detail, string InsertUser)
        {
            bool rpta = false;

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[adm].[uspAddLeadership]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                //Insert Parameters
                SqlParameter Title = new SqlParameter
                {
                    ParameterName = "@FullName",
                    SqlDbType     = SqlDbType.VarChar,
                    Size          = 100,
                    Value         = Detail.FullName.Trim()
                };
                SqlCmd.Parameters.Add(Title);

                SqlParameter Description = new SqlParameter
                {
                    ParameterName = "@Description",
                    SqlDbType     = SqlDbType.VarChar,
                    Value         = Detail.Description.Trim()
                };
                SqlCmd.Parameters.Add(Description);

                SqlParameter pImage = new SqlParameter
                {
                    ParameterName = "@Image",
                    SqlDbType     = SqlDbType.VarChar,
                    Size          = 500,
                    Value         = Detail.ImagePath
                };
                SqlCmd.Parameters.Add(pImage);

                SqlParameter Link = new SqlParameter
                {
                    ParameterName = "@ActionLink",
                    SqlDbType     = SqlDbType.VarChar,
                    Size          = 50,
                    Value         = Detail.ActionLink
                };
                SqlCmd.Parameters.Add(Link);

                SqlParameter pOrder = new SqlParameter
                {
                    ParameterName = "@Order",
                    SqlDbType     = SqlDbType.Int,
                    Value         = Detail.Order
                };
                SqlCmd.Parameters.Add(pOrder);

                SqlParameter ParInsertUser = new SqlParameter
                {
                    ParameterName = "@InsertUser",
                    SqlDbType     = SqlDbType.VarChar,
                    Size          = 50,
                    Value         = InsertUser
                };
                SqlCmd.Parameters.Add(ParInsertUser);

                //Exec Command
                SqlCmd.ExecuteNonQuery();

                rpta = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }
            return(rpta);
        }
 public static string GetPlayerLeadershipName(Leadership leadership)
 {
     return(HM.Resources.Constants.EnumNames.PlayerLeadershipNames[(int)leadership]);
 }