public String DoLike(int exId)
        {
            int uid = (int)Session["id"];

            try
            {
                like lk = db.likes.First(l => l.expid == exId && l.userid == uid);
                db.likes.Remove(lk);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                like l = new like();
                l.userid = uid;
                l.expid  = exId;
                db.likes.Add(l);
                db.SaveChanges();
            }

            experience e = db.experiences.Find(exId);

            return(e.likes.Count + "");
            //get user id from Session
            // check either this person already likes this post.
            // Exceptio ===> make like object, set values, Add to db, save changes.
        }
Beispiel #2
0
        private void awardExperience(GameObject instigator)
        {
            experience exp = instigator.GetComponent <experience>();

            if (exp == null)
            {
                return;
            }
            exp.GainExperience(GetComponent <BaseStats>().GetStat(Stats.experienceReward));
        }
        public void AddExperience(int employe_experience, string employe_level)
        {
            experience exp = new experience();

            exp.employe_experience = employe_experience;
            exp.employe_level      = employe_level;


            var db = new newdataEntities();

            db.experiences.Add(exp);
            db.SaveChanges();
            db.Dispose();
        }
        public ActionResult Addpost()
        {
            ViewBag.Message = "Share Experience.";
            //string uH = Request["userHome"];
            string     post = Request["postdata"];
            experience e    = new experience();

            e.experimenttext = post;
            e.DateTime       = DateTime.Now;
            //user us = (user)db.users.First(u => u.email == Session["email"]);
            e.userid = (int)Session["id"];

            db.experiences.Add(e);
            db.SaveChanges();
            return(RedirectToAction("userHome"));
        }
Beispiel #5
0
 public checkLevel(experience, level)
 {
     if (level == 1)
     {
         if (exp > 5)
         {
             this.gainLevel();
         }
     }
     else if (level == 2)
     {
         if (exp > 25)
         {
             this.gainLevel();
         }
     }
     else if (level == 3)
     {
         if (exp > 75)
         {
             this.gainLevel();
         }
     }
     else if (level == 4)
     {
         if (exp > 175)
         {
             this.gainLevel();
         }
     }
     else if (level == 5)
     {
         if (exp > 300)
         {
             this.gainLevel();
         }
     }
 }
        private int CalculateLevel()
        {
            experience experience = GetComponent <experience>();

            if (experience == null)
            {
                return(startingLevel);
            }

            float currentXP        = experience.GetPoints();
            int   penultimateLevel = progression.GetLevels(Stats.experienceToLevelUp, characterClass);

            for (int level = 1; level <= penultimateLevel; level++)
            {
                float XPToLevelUp = progression.GetStat(Stats.experienceToLevelUp, characterClass, level);
                if (XPToLevelUp > currentXP)
                {
                    return(level);
                }
            }

            return(penultimateLevel + 1);
        }
 private void Awake()
 {
     experience   = GetComponent <experience>();
     currentLevel = new LazyValue <int>(CalculateLevel);
 }
 private void Awake()
 {
     exp = GameObject.FindGameObjectWithTag("Player").GetComponent <experience>();
 }
Beispiel #9
0
        public ActionResult Create(EmployeeFamilyViewModel empdata, HttpPostedFileBase photo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (empdata.id == 0) // create section
                    {
                        if (photo != null && photo.ContentLength > 0)
                        {
                            string photopath = Server.MapPath("~/UserImage");
                            if (!Directory.Exists(photopath))
                            {
                                Directory.CreateDirectory(photopath);
                            }
                            string[] imageName = photo.FileName.Split('.').ToArray();
                            string   extension = imageName[(imageName.Length - 1)].ToString();
                            string   fileName  = DateTime.Now.ToString("yyMMddmmhhss") + "_" + photo.FileName + "." + extension;
                            string   filePath  = Path.Combine(photopath, fileName);
                            photo.SaveAs(filePath); //saving photo
                            empdata.photo = fileName;
                        }

                        employee newEmpData = new employee();
                        newEmpData.fullName      = empdata.fullName;
                        newEmpData.dob           = empdata.dob;
                        newEmpData.gender        = empdata.gender;
                        newEmpData.maritalStatus = empdata.maritalStatus;
                        newEmpData.bloodGroup    = empdata.bloodGroup;
                        newEmpData.photo         = empdata.photo;
                        newEmpData.createdBy     = User.Identity.Name;
                        newEmpData.createdDate   = DateTime.Now;
                        dbcontext.employee.Add(newEmpData);

                        dbcontext.SaveChanges();

                        foreach (var item in empdata.FamilyDetails)
                        {
                            familyDetail famData = new familyDetail();
                            famData.relationship = item.relationship;
                            famData.employeeId   = newEmpData.id;
                            famData.name         = item.name;
                            famData.occupation   = item.occupation;
                            famData.dob          = item.dob;
                            famData.createdBy    = User.Identity.Name;
                            famData.createdDate  = DateTime.Now;
                            dbcontext.familyDetail.Add(famData);
                        }
                        //educaton
                        //
                        foreach (var item in empdata.Experiences)
                        {
                            experience exp = new experience()
                            {
                                employeeId     = newEmpData.id,
                                nameOfEmployer = item.nameOfEmployer,
                                empStatus      = item.empStatus,
                                durationFrom   = item.durationFrom,
                                durationTo     = item.durationTo,
                                tenure         = item.tenure,
                                status         = true,
                                createdBy      = User.Identity.Name,
                                createdDate    = DateTime.Now
                            };
                            dbcontext.experience.Add(exp);
                        }
                        dbcontext.SaveChanges();

                        //bool isCreated = this._userProfileService.CreateUserProfile(userprofiles);
                        return(RedirectToAction("Index"));
                    }

                    else //update section
                    {
                        employee previousRecord = dbcontext.employee.Where(a => a.id == empdata.id).FirstOrDefault();
                        //UserProfile previousRecord = this._userProfileService.GetUserProfileById(userprofiles.Id);
                        //check new file selected or not
                        if (photo != null && photo.ContentLength > 0)
                        {
                            string photosavingpath = Server.MapPath("~/UserImage/");
                            //delete old one
                            if (!string.IsNullOrEmpty(previousRecord.photo) && Directory.Exists(photosavingpath))
                            {
                                string fullphotopath = photosavingpath + previousRecord.photo;
                                System.IO.File.Delete(fullphotopath);
                            }
                            //save file
                            string[] imageName = photo.FileName.Split('.').ToArray();
                            string   extension = imageName[(imageName.Length - 1)].ToString();
                            string   fileName  = DateTime.Now.ToString("yyMMddmmhhss") + "_" + photo.FileName + "." + extension;
                            string   filePath  = Path.Combine(photosavingpath, fileName);
                            photo.SaveAs(filePath); //saving photo
                            previousRecord.photo = fileName;
                        }
                        previousRecord.modifiedBy   = empdata.modifiedBy + ";" + User.Identity.Name;
                        previousRecord.modifiedDate = empdata.modifiedDate + ";" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        dbcontext.Entry <employee>(previousRecord).State = EntityState.Modified;
                        //for family detail table
                        foreach (var fd in empdata.FamilyDetails)
                        {
                            familyDetail prevFamilyDetail = new familyDetail();
                            prevFamilyDetail              = dbcontext.familyDetail.Find(fd.id);
                            prevFamilyDetail.name         = fd.name;
                            prevFamilyDetail.relationship = fd.relationship;
                            prevFamilyDetail.occupation   = fd.occupation;
                            prevFamilyDetail.dob          = fd.dob;
                            dbcontext.Entry <familyDetail>(prevFamilyDetail).State = EntityState.Modified;
                        }

                        //for experience table
                        //first delete previous recorded experiences, then add current
                        List <experience> prevExperiences = dbcontext.experience.Where(a => a.employeeId == empdata.id).ToList();
                        dbcontext.experience.RemoveRange(prevExperiences);

                        foreach (var item in empdata.Experiences)
                        {
                            experience exp = new experience()
                            {
                                employeeId     = empdata.id,
                                nameOfEmployer = item.nameOfEmployer,
                                empStatus      = item.empStatus,
                                durationFrom   = item.durationFrom,
                                durationTo     = item.durationTo,
                                tenure         = item.tenure,
                                status         = true,
                                createdBy      = User.Identity.Name,
                                createdDate    = DateTime.Now
                            };
                            dbcontext.experience.Add(exp);
                        }

                        dbcontext.SaveChanges();

                        //bool isUpdated = this._userProfileService.UpdateUserProfile(userprofiles);
                        return(RedirectToAction("Index"));
                    }
                }
                //List<Province> provinceList = this._provinceServices.GetAllProvinces();
                //ViewBag.Province = new SelectList(provinceList, "Id", "Name");
                return(View(empdata));
            }
            catch (Exception ex)
            {
                throw;
            }
        }