public ActionResult DeleteConfirmed(short id)
        {
            tbl_Group tbl_Group = db.tbl_Group.Find(id);

            db.tbl_Group.Remove(tbl_Group);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,name,description,status,createdTime,updatedTime,createdBy,updatedBy")] tbl_Group tbl_Group)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Group).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_Group));
 }
        public ActionResult Create([Bind(Include = "id,name,description,status")] tbl_Group tbl_Group)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Group.Add(tbl_Group);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_Group));
        }
Esempio n. 4
0
        public ActionResult GroupDelete(int id)
        {
            userSession = Session["user"] as tbl_User;
            if (!userSession.tbl_Permission.permission_Id.Equals(1))
            {
                return(HttpNotFound());
            }
            tbl_Group tbl_Group = db.tbl_Group.Find(id);

            db.tbl_Group.Remove(tbl_Group);
            db.SaveChanges();
            return(RedirectToAction("GroupIndex"));
        }
        // GET: tbl_Group/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Group tbl_Group = db.tbl_Group.Find(id);

            if (tbl_Group == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_Group));
        }
Esempio n. 6
0
        public IHttpActionResult DeleteGroup(Int64 id)
        {
            tbl_Group  itemOut    = null;
            BaseOutput baseOutput = businessOperation.DeleteGroup(id, out itemOut);

            if (baseOutput.ResultCode == 1)
            {
                return(Ok(itemOut));
            }
            else
            {
                return(Content(HttpStatusCode.BadRequest, baseOutput));
            }
        }
Esempio n. 7
0
        public IHttpActionResult GetGroupByName(string name)
        {
            tbl_Group  itemOut    = null;
            BaseOutput baseOutput = businessOperation.GetGroupByName(name, out itemOut);

            if (baseOutput.ResultCode == 1)
            {
                return(Ok(itemOut));
            }
            else
            {
                return(Content(HttpStatusCode.BadRequest, baseOutput));
            }
        }
Esempio n. 8
0
 public ActionResult GroupEdit([Bind(Include = "group_Id,group_Name")] tbl_Group tbl_Group)
 {
     userSession = Session["user"] as tbl_User;
     if (!userSession.tbl_Permission.permission_Id.Equals(1))
     {
         return(HttpNotFound());
     }
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Group).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("GroupIndex"));
     }
     return(View(tbl_Group));
 }
Esempio n. 9
0
        public BaseOutput UpdateGroup(tbl_Group item, out tbl_Group itemOut)
        {
            BaseOutput baseOutput;

            itemOut = null;
            try
            {
                tbl_Group group = operation.UpdateGroup(item);
                itemOut = group;
                return(baseOutput = new BaseOutput(true, BOResultTypes.Success.GetHashCode(), BOBaseOutputResponse.SuccessResponse, ""));
            }
            catch (Exception ex)
            {
                return(baseOutput = new BaseOutput(false, BOResultTypes.Danger.GetHashCode(), BOBaseOutputResponse.DangerResponse, ex.Message));
            }
        }
Esempio n. 10
0
        public BaseOutput GetGroupByName(string name, out tbl_Group itemOut)
        {
            BaseOutput baseOutput;

            itemOut = null;
            try
            {
                var group = operation.GetGroupByName(name);;

                itemOut = group;
                return(baseOutput = new BaseOutput(true, BOResultTypes.Success.GetHashCode(), BOBaseOutputResponse.SuccessResponse, ""));
            }
            catch (Exception ex)
            {
                return(baseOutput = new BaseOutput(false, BOResultTypes.Danger.GetHashCode(), BOBaseOutputResponse.DangerResponse, ex.Message));
            }
        }
Esempio n. 11
0
        public ActionResult Edit(int id)
        {
            GroupVM viewModel = new GroupVM();

            viewModel = poulateDropDownList(viewModel);
            CRUDOperation dataOperations = new CRUDOperation();

            tbl_Group tblItem = dataOperations.GetGroupByID(id);

            viewModel.GroupID     = id;
            viewModel.GroupType   = tblItem.GroupType == null?0:(int)tblItem.GroupType;
            viewModel.GroupName   = tblItem.Name;
            viewModel.Description = tblItem.Description;
            viewModel.StartLimit  = tblItem.StartLimit == null?0:(decimal)tblItem.StartLimit;
            viewModel.EndLimit    = tblItem.EndLimit == null?0:(decimal)tblItem.EndLimit;
            return(View(viewModel));
        }
Esempio n. 12
0
        public ActionResult Edit(GroupVM viewModel)
        {
            try
            {
                var UserProfile = (UserProfileSessionData)this.Session["UserProfile"];
                if (UserProfile != null)
                {
                    if (ModelState.IsValid)
                    {
                        tbl_Group item = new tbl_Group()
                        {
                            ID          = viewModel.GroupID,
                            GroupType   = viewModel.GroupType,
                            Name        = viewModel.GroupName,
                            Description = viewModel.Description,
                            StartLimit  = viewModel.StartLimit,
                            EndLimit    = viewModel.EndLimit,
                            UpdateDate  = DateTime.Now,
                            UpdateUser  = UserProfile.UserId
                        };

                        CRUDOperation dataOperations = new CRUDOperation();
                        tbl_Group     dbItem         = dataOperations.UpdateGroup(item);
                        if (dbItem != null)
                        {
                            TempData["success"] = "Ok";
                            TempData["message"] = "Məlumatlar uğurla dəyişdirildi";
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            TempData["success"] = "notOk";
                            TempData["message"] = "Məlumatlar dəyişdirilərkən xəta baş verdi";
                            return(RedirectToAction("Index"));
                        }
                    }
                }

                throw new ApplicationException("Invalid model");
            }
            catch (ApplicationException ex)
            {
                viewModel = poulateDropDownList(viewModel);
                return(View(viewModel));
            }
        }
Esempio n. 13
0
        public IHttpActionResult AddGroup(tbl_Group item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            tbl_Group  itemOut    = null;
            BaseOutput baseOutput = businessOperation.AddGroup(item, out itemOut);

            if (baseOutput.ResultCode == 1)
            {
                return(Ok(itemOut));
            }
            else
            {
                return(Content(HttpStatusCode.BadRequest, baseOutput));
            }
        }
Esempio n. 14
0
        public BaseOutput GetDynamicGroupUsersByGroupID(Int64 pointGroupID, Int64 priceGroupID, out List <UserDTO> itemsOut)
        {
            BaseOutput baseOutput;

            itemsOut = null;
            decimal         pointStartLimit = 0;
            decimal         pointEndLimit   = 0;
            decimal         priceStartLimit = 0;
            decimal         priceEndLimit   = 0;
            GroupRepository repository      = new GroupRepository();

            try
            {
                tbl_Group pointGroup = new tbl_Group();
                if (pointGroupID > 0)
                {
                    pointGroup = operation.GetGroupByID(pointGroupID);
                    if (pointGroup != null)
                    {
                        pointStartLimit = pointGroup.StartLimit == null?0:(decimal)pointGroup.StartLimit;
                        pointEndLimit   = pointGroup.EndLimit == null ? 0 : (decimal)pointGroup.EndLimit;
                    }
                }

                tbl_Group priceGroup = new tbl_Group();
                if (priceGroupID > 0)
                {
                    priceGroup = operation.GetGroupByID(priceGroupID);
                    if (priceGroup != null)
                    {
                        priceStartLimit = priceGroup.StartLimit == null ? 0 : (decimal)priceGroup.StartLimit;
                        priceEndLimit   = priceGroup.EndLimit == null ? 0 : (decimal)priceGroup.EndLimit;
                    }
                }

                var users = repository.GetDynamicGroupUsersByGroupID(pointGroupID, pointStartLimit, pointEndLimit, priceGroupID, priceStartLimit, priceEndLimit);
                itemsOut = users;
                return(baseOutput = new BaseOutput(true, BOResultTypes.Success.GetHashCode(), BOBaseOutputResponse.SuccessResponse, ""));
            }
            catch (Exception ex)
            {
                return(baseOutput = new BaseOutput(false, BOResultTypes.Danger.GetHashCode(), BOBaseOutputResponse.DangerResponse, ex.Message));
            }
        }
Esempio n. 15
0
        public ActionResult GroupDelete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Group tbl_Group = db.tbl_Group.Find(id);

            if (tbl_Group == null)
            {
                return(HttpNotFound());
            }
            userSession = Session["user"] as tbl_User;
            if (!userSession.tbl_Permission.permission_Id.Equals(1))
            {
                return(HttpNotFound());
            }
            return(View(tbl_Group));
        }
    /// <summary>
    /// This function add Client Contacts to group
    /// </summary>
    /// <param name="gr"></param>   
    /// <returns></returns>
    public int AddClientContactsToGroup(ClientContactAddToGroup gr)
    {
        var context = new dbDataContext();
        // check for the group
        if (gr.Group.GroupId == 0 && !string.IsNullOrEmpty(gr.Group.Name.Trim()))
        {
            //create new group
            var group = new tbl_Group
             {
                 UserId = gr.Group.UserId,
                 CreatedDate = DateTime.Now,
                 IsPublic = gr.Group.IsPublic,
                 Name = gr.Group.Name.Trim()
             };
            context.tbl_Groups.InsertOnSubmit(group);
            context.SubmitChanges();
            gr.Group.GroupId = group.GroupId;
        }
        else if (gr.Group.GroupId == 0)
            return -1;

        //add client and contacts 
        if (!string.IsNullOrEmpty(gr.SelectedIds))
        {
            //If selected Ids were passed
            foreach (var id in gr.SelectedIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
            {
                var contactId = int.Parse(id);
                var contactCount =
                    context.tbl_CandidateGroups.Count(t => t.GroupId == gr.Group.GroupId && t.CandidateId == contactId);
                if (contactCount == 0)
                {
                    var clientContactGroup = new tbl_CandidateGroup
                    {
                        CandidateId = contactId,
                        GroupId = gr.Group.GroupId
                    };
                    context.tbl_CandidateGroups.InsertOnSubmit(clientContactGroup);
                    context.SubmitChanges();
                }
            } 
        }
        else
        {
            //use stored procedure to insert contacts/clients
            var filters = gr.Filter;
            // setup the parameters
            SqlParameter[] parameters = {
	                       new SqlParameter("@GroupToAdd", gr.Group.GroupId), 
                           new SqlParameter("@ConsultantId", filters.ConsultantId),
                           new SqlParameter("@UserId", filters.UserId),
                           new SqlParameter("@ClientId", filters.ClientId ),
                           new SqlParameter("@ContactStatuses", filters.ContactStatusIds),
                           new SqlParameter("@ClientStatuses", filters.ClientStatusIds),
                           new SqlParameter("@Client", filters.Client),
                           new SqlParameter("@Forename", filters.Forename),
                           new SqlParameter("@Surname", filters.Surname),
                           new SqlParameter("@Email", filters.Email),
                           new SqlParameter("@JobTitle", filters.JobTitle),   
                           new SqlParameter("@Employer", filters.Employer),
	                       new SqlParameter("@Sectors", filters.Sectors),
	                       new SqlParameter("@Locations", filters.Locations), 
                           new SqlParameter("@Qualifications", filters.Qualifications),
	                       new SqlParameter("@Skills", filters.Skills),
	                       new SqlParameter("@MinSalary", filters.MinSalary),
	                       new SqlParameter("@MaxSalary", filters.MaxSalary),
	                       new SqlParameter("@Keyword", filters.Keyword),
	                       new SqlParameter("@SortBy", filters.SortBy), 
	                       new SqlParameter("@Deleted" ,filters.Deleted),	
	                       new SqlParameter("@LastUpdatedDateFrom" ,filters.LastUpdatedDateFrom),
	                       new SqlParameter("@LastUpdatedDateTo", filters.LastUpdatedDateTo),
	                       new SqlParameter("@VacancyType" ,filters.VacancyType),
                           new SqlParameter("@Hours" ,filters.Hours), 
                           new SqlParameter("@GroupId" ,filters.GroupId),
                           new SqlParameter("@LocationRadius" ,filters.LocationRadius),
	                       new SqlParameter("@RetrieveType",filters.RetrieveType)
            };
            // setup the connection
            var conn = new Sql_DataAccess(_connString);
            //execute th stored procedure
            conn.GetDataSetFromSP("AddClientsContactsToGroupsByFilter", parameters); 
        } 
        return gr.Group.GroupId;
    }
        public static void Seed(this ModelBuilder modelBuilder)
        {
            //if (!System.Diagnostics.Debugger.IsAttached)
            //    System.Diagnostics.Debugger.Launch();

            //context.Privilliges.RemoveRange(context.Privilliges.ToList());
            //context.Menus.RemoveRange(context.Menus.ToList());
            //context.SaveChanges();
            //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [tbl_Privillige] ON");
            //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [tbl_Menu] ON");
            //context.Database.ExecuteSqlCommand("TRUNCATE TABLE [tbl_Privillige]");
            //context.Database.ExecuteSqlCommand("TRUNCATE TABLE [tbl_Menu]");
            //DBCC CHECKIDENT('tbl_Privillige',RESEED, 0)

            #region Seed
            #region UserTypes
            tbl_UserType ut1 = new tbl_UserType()
            {
                NameAr = "مريض",
                NameEn = "Patient"
            };
            tbl_UserType ut2 = new tbl_UserType()
            {
                NameAr = "طبيب",
                NameEn = "Doctor"
            };
            tbl_UserType ut3 = new tbl_UserType()
            {
                NameAr = "ادارة النظام",
                NameEn = "Administrator"
            };
            fillbase(ut1);
            fillbase(ut2);
            fillbase(ut3);
            modelBuilder.Entity <tbl_UserType>().HasData(ut1, ut2, ut3);

            #endregion
            #region Privilliges
            tbl_Privillige Page_administration = new tbl_Privillige()
            {
                Key    = common.Enums.Enum_Privilliges.Page_administration.ToString(),
                NameAr = common.Enums.Enum_Privilliges.Page_administration.ToString(),
                NameEn = common.Enums.Enum_Privilliges.Page_administration.ToString()
            };
            tbl_Privillige Page_Groups = new tbl_Privillige()
            {
                Key    = common.Enums.Enum_Privilliges.Page_Groups.ToString(),
                NameAr = common.Enums.Enum_Privilliges.Page_Groups.ToString(),
                NameEn = common.Enums.Enum_Privilliges.Page_Groups.ToString()
            };
            tbl_Privillige Page_Groups_Add = new tbl_Privillige()
            {
                Key    = common.Enums.Enum_Privilliges.Page_Groups_Add.ToString(),
                NameAr = common.Enums.Enum_Privilliges.Page_Groups_Add.ToString(),
                NameEn = common.Enums.Enum_Privilliges.Page_Groups_Add.ToString()
            };
            tbl_Privillige Page_Users = new tbl_Privillige()
            {
                Key    = common.Enums.Enum_Privilliges.Page_Users.ToString(),
                NameAr = common.Enums.Enum_Privilliges.Page_Users.ToString(),
                NameEn = common.Enums.Enum_Privilliges.Page_Users.ToString()
            };
            tbl_Privillige Page_Users_Add = new tbl_Privillige()
            {
                Key    = common.Enums.Enum_Privilliges.Page_Users_Add.ToString(),
                NameAr = common.Enums.Enum_Privilliges.Page_Users_Add.ToString(),
                NameEn = common.Enums.Enum_Privilliges.Page_Users_Add.ToString()
            };

            fillbase(Page_Groups);
            fillbase(Page_Groups_Add);
            fillbase(Page_Users);
            fillbase(Page_Users_Add);
            fillbase(Page_administration);
            modelBuilder.Entity <tbl_Privillige>().HasData(Page_Groups, Page_Groups_Add, Page_Users, Page_Users_Add, Page_administration);

            #endregion
            #region Privilliges_Groups
            tbl_Group AdminGroup = new tbl_Group()
            {
                NameAr = common.Enums.Enum_PrivilligesGroup.AdminGroup.ToString(),
                NameEn = common.Enums.Enum_PrivilligesGroup.AdminGroup.ToString()
            };
            tbl_Group DoctorGroup = new tbl_Group()
            {
                NameAr = common.Enums.Enum_PrivilligesGroup.DoctorGroup.ToString(),
                NameEn = common.Enums.Enum_PrivilligesGroup.DoctorGroup.ToString()
            };
            tbl_Group PatientGroup = new tbl_Group()
            {
                NameAr = common.Enums.Enum_PrivilligesGroup.PatientGroup.ToString(),
                NameEn = common.Enums.Enum_PrivilligesGroup.PatientGroup.ToString()
            };
            fillbase(AdminGroup);
            fillbase(DoctorGroup);
            fillbase(PatientGroup);
            modelBuilder.Entity <tbl_Group>().HasData(AdminGroup, DoctorGroup, PatientGroup);

            #endregion
            #region Menu

            List <tbl_Menu> Menus = new List <tbl_Menu>();


            #region Security

            //tbl_Menu Menu_Security_Privilliges = new tbl_Menu()
            //{

            //    NameAr = "Privilliges",
            //    icon = "ion-card",
            //    NameEn = "Privilliges",
            //    link = "/pages/Security/privilliges/Index",

            //};
            tbl_Menu Menu_Security = new tbl_Menu()
            {
                ParentID     = null,
                NameAr       = " الادارة",
                NameEn       = "administration",
                icon         = "ion-settings",
                link         = "",
                PrivilligeID = Page_administration.ID,
                //Children = new List<tbl_Menu>()
                //{
                //    Menu_Security_Users,
                //    Menu_Security_Groups,
                //}
            };
            fillbase(Menu_Security);
            tbl_Menu Menu_Security_Groups = new tbl_Menu()
            {
                ID       = Guid.NewGuid(),
                ParentID = Menu_Security.ID,
                NameAr   = "المجموعات",
                icon     = "fa fa-object-group",
                NameEn   = "groups",
                link     = "/pages/administration/groups",
            };
            fillbase(Menu_Security_Groups);

            tbl_Menu Menu_Security_Users = new tbl_Menu()
            {
                ID       = Guid.NewGuid(),
                ParentID = Menu_Security.ID,

                NameAr = "المستخدمون",
                NameEn = "Users",
                icon   = "ion-person-stalker",
                link   = "/pages/administration/users",
            };
            fillbase(Menu_Security_Users);

            Menus.Add(Menu_Security);
            Menus.Add(Menu_Security_Groups);
            Menus.Add(Menu_Security_Users);
            foreach (var m in Menus)
            {
                fillbase(m);

                foreach (var m_child in m.Children)
                {
                    fillbase(m_child);
                }
            }
            modelBuilder.Entity <tbl_Menu>().HasData(Menu_Security, Menu_Security_Users, Menu_Security_Groups);

            #endregion
            #endregion
            #region Settings
            tbl_Setting sett1 = new tbl_Setting()
            {
                Conf_Key   = "Active_Directory_Domain",
                Conf_Value = "GETGROUP.com"
            };

            fillbase(sett1);
            modelBuilder.Entity <tbl_Setting>().HasData(sett1);


            #endregion

            #region Users
            tbl_User ahmedadmin = new tbl_User()
            {
                Email               = "*****@*****.**",
                NameAr              = "احمد حسن",
                NameEn              = "ahmed hassan",
                Password            = "******",
                isActivated         = true,
                Mobile              = "01111376958",
                Name                = "*****@*****.**",
                ActivationStartDate = DateTime.Now.AddDays(-1),
                ActivationEndDate   = null,
                UserTypeID          = ut3.ID
            };
            tbl_User user1 = new tbl_User()
            {
                Email               = "*****@*****.**",
                NameAr              = "admin1",
                NameEn              = "admin1",
                Password            = "******",
                isActivated         = true,
                ActivationStartDate = DateTime.Now.AddDays(-1),
                ActivationEndDate   = DateTime.MaxValue
            };
            tbl_User user2 = new tbl_User()
            {
                Email               = "*****@*****.**",
                NameAr              = "admin2",
                NameEn              = "admin2",
                Password            = "******",
                isActivated         = true,
                ActivationStartDate = DateTime.Now.AddDays(-1),
                ActivationEndDate   = DateTime.MaxValue,
            };
            fillbase(ahmedadmin);
            fillbase(user1);
            fillbase(user2);

            modelBuilder.Entity <tbl_User>().HasData(ahmedadmin);

            List <tbl_Privilligetbl_User> usersInPriv = new List <tbl_Privilligetbl_User>()
            {
                new tbl_Privilligetbl_User()
                {
                    //User = ahmedadmin,
                    tbl_User_ID       = ahmedadmin.ID,
                    tbl_Privillige_ID = Page_Groups.ID,
                    //Privillige = Page_Groups
                },
                new tbl_Privilligetbl_User()
                {
                    //User = ahmedadmin,
                    tbl_User_ID       = ahmedadmin.ID,
                    tbl_Privillige_ID = Page_Groups_Add.ID,
                    //Privillige = Page_Groups_Add
                },
                new tbl_Privilligetbl_User()
                {
                    //User = ahmedadmin,
                    tbl_User_ID       = ahmedadmin.ID,
                    tbl_Privillige_ID = Page_Users.ID,
                    //Privillige = Page_Users
                },
                new tbl_Privilligetbl_User()
                {
                    //User = ahmedadmin,
                    tbl_User_ID       = ahmedadmin.ID,
                    tbl_Privillige_ID = Page_Users_Add.ID,
                    //Privillige = Page_Users_Add
                },
                new tbl_Privilligetbl_User()
                {
                    //User = ahmedadmin,
                    tbl_User_ID       = ahmedadmin.ID,
                    tbl_Privillige_ID = Page_administration.ID,
                    //Privillige = Page_Users_Add
                }
            };
            //var ahmedadminPriv0 = new tbl_Privilligetbl_User()
            //{
            //    User = ahmedadmin,
            //    Privillige = Page_administration

            //};
            //var ahmedadminPriv1 = new tbl_Privilligetbl_User()
            //{
            //    User = ahmedadmin,
            //    Privillige = Page_Groups

            //};
            //var ahmedadminPriv2 = new tbl_Privilligetbl_User()
            //{
            //    User = ahmedadmin,
            //    Privillige = Page_Users

            //};
            //var ahmedadminPriv3 = new tbl_Privilligetbl_User()
            //{
            //    User = ahmedadmin,
            //    Privillige = Page_Groups_Add

            //};
            //var ahmedadminPriv4 = new tbl_Privilligetbl_User()
            //{
            //    User = ahmedadmin,
            //    Privillige = Page_Users_Add

            //};
            modelBuilder.Entity <tbl_Privilligetbl_User>().HasData(usersInPriv[0], usersInPriv[1], usersInPriv[2], usersInPriv[3], usersInPriv[4]);

            #endregion


            #endregion
            //            context.Database.ExecuteSqlCommand(@"CREATE SEQUENCE [dbo].[ReferenceNmberSequence]
            // AS[bigint]
            // START WITH 40425942
            // INCREMENT BY 1
            // MINVALUE - 9223372036854775808
            // MAXVALUE 99999999
            // CACHE
            //GO");

            //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [tbl_Privillige] OFF");
            //context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [tbl_Menu] OFF");
        }
Esempio n. 18
0
 partial void Inserttbl_Group(tbl_Group instance);
Esempio n. 19
0
 partial void Updatetbl_Group(tbl_Group instance);
Esempio n. 20
0
 partial void Deletetbl_Group(tbl_Group instance);