Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            WorkRole workRole = db.WorkRoles.Find(id);

            db.WorkRoles.Remove(workRole);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "WorkRoleId,RoleName,RoleDescription")] WorkRole workRole)
 {
     if (ModelState.IsValid)
     {
         db.Entry(workRole).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(workRole));
 }
Exemple #3
0
        public MatchedWorkerDto(int id, Worker w, WorkRole role)
        {
            RouteWorkerId = id;
            Id            = w.Id;
            Cn            = w.Cn;
            Name          = w.Name;
            Rfid          = w.Rfid;
            Photo         = w.Photo != null?Convert.ToBase64String(w.Photo) : null;

            ArticleTypeList = role.ArticleTypeList;
            Duties          = role.Duties;
            WorkRoleName    = role.Name;
        }
Exemple #4
0
        // GET: WorkRoles/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WorkRole workRole = db.WorkRoles.Find(id);

            if (workRole == null)
            {
                return(HttpNotFound());
            }
            return(View(workRole));
        }
Exemple #5
0
        private string GetAnotherRoleName(WorkRole workRole)
        {
            string doubleRoles = SettingManager.GetSettingValueAsync(AppSettingNames.Rule.DoubleArticleRoles).Result;

            string[] array = doubleRoles.Split('|');
            if (array[0] == workRole.Name)
            {
                return(array[1]);
            }
            if (array[1] == workRole.Name)
            {
                return(array[0]);
            }
            return(null);
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "WorkRoleId,RoleName,RoleDescription")] WorkRole workRole)
        {
            if (ModelState.IsValid)
            {
                string currentUserId = User.Identity.GetUserId();

                Company company = db.Companies.Where(c => c.CAId == currentUserId)
                                  .FirstOrDefault();
                int companyID = company.CompanyId;

                workRole.CompanyId = companyID;

                db.WorkRoles.Add(workRole);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(workRole));
        }
Exemple #7
0
        private static Employee GetSuperior(DataContext ctx, WorkRole workRole)
        {
            if (WorkRole.BusinessAnalyst == workRole ||
                WorkRole.TeamLeader == workRole ||
                WorkRole.HumanResourceManager == workRole ||
                WorkRole.ProjectManager == workRole ||
                WorkRole.OfficeAssistant == workRole)
            {
                return(ctx.Employees.SingleOrDefault(e => e.WorkRole == WorkRole.CEO));
            }
            else if (WorkRole.SoftwareTester == workRole ||
                     WorkRole.SoftwareEngineer == workRole)
            {
                return(ctx.Employees.SingleOrDefault(e => e.WorkRole == WorkRole.TeamLeader));
            }
            else if (WorkRole.CEO == workRole)
            {
                throw new CeoSuperiorException();
            }

            throw new InvalidWorkRoleException(workRole.ToString());
        }
Exemple #8
0
        private static OrganizationUnit GetOrganizationUnit(DataContext ctx, WorkRole workRole)
        {
            if (WorkRole.BusinessAnalyst == workRole ||
                WorkRole.CEO == workRole ||
                WorkRole.HumanResourceManager == workRole ||
                WorkRole.ProjectManager == workRole)
            {
                return(ctx.OrganizationUnits.SingleOrDefault(o => o.Abbreviation == "MGT"));
            }
            else if (WorkRole.SoftwareTester == workRole ||
                     WorkRole.SoftwareEngineer == workRole ||
                     WorkRole.TeamLeader == workRole)
            {
                return(ctx.OrganizationUnits.SingleOrDefault(o => o.Abbreviation == "IT"));
            }
            else if (WorkRole.OfficeAssistant == workRole)
            {
                return(ctx.OrganizationUnits.SingleOrDefault(o => o.Abbreviation == "BO"));
            }

            throw new InvalidWorkRoleException(workRole.ToString());
        }
Exemple #9
0
 public static string[] GetWorkRoleTitles(this WorkRole workRole)
 {
     return(WorkRoleTitles.Values.ToArray());
 }
Exemple #10
0
 public static string GetTitleFromWorkRole(this WorkRole workRole)
 {
     return(WorkRoleTitles[workRole]);
 }
Exemple #11
0
        private RouteWorkerCacheItem FindAnotherRouteWorker(List <RouteWorkerCacheItem> workers, WorkRole workRole)
        {
            string anotherRole = GetAnotherRoleName(workRole);

            if (anotherRole != null)
            {
                foreach (var w in workers)
                {
                    var role = _workRoleCache[w.WorkRoleId];
                    if (role.Name == anotherRole)
                    {
                        return(w);
                    }
                }
            }
            return(null);
        }