Ejemplo n.º 1
0
    public static AdminModel GetLoginAdmin(int AdminId)
    {
        AdminModel model = null;

        try
        {
            if (model == null)
            {
                AdminBLL          ab   = new AdminBLL();
                List <AdminModel> list = new List <AdminModel>();
                int count = 0;
                ab.GetAdminList(1, 1, AdminId, null, null, null, null, null, out count, out list);
                if (list.Count == 1)
                {
                    model = list[0];
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return(model);
    }
Ejemplo n.º 2
0
    public static AdminModel GetLoginAdmin(HttpContext context)
    {
        AdminModel model = null;

        if (context.User.Identity.IsAuthenticated)
        {
            if (context.Session != null && context.Session["admin"] != null)
            {
                model = (AdminModel)context.Session["admin"];
            }

            try
            {
                if (model == null)
                {
                    AdminBLL          ab   = new AdminBLL();
                    List <AdminModel> list = new List <AdminModel>();
                    int count = 0;
                    ab.GetAdminList(1, 1, Convert.ToInt32(context.User.Identity.Name), null, null, null, null, null, out count, out list);
                    //ab.GetAdminList(1, 1, 1, null, null, null, null, null, out count, out list);
                    if (list.Count == 1)
                    {
                        model = list[0];
                        context.Session["admin"] = model;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        return(model);
    }
Ejemplo n.º 3
0
 public AdminPresenter(IWorkerView workerView, AdminModel userModel)
 {
     _userModel = userModel;
     _workerView = workerView;
     _workerView.createAdminView();
     workerView.show();
 }
        public JsonResult AddItemSubType([FromBody] AdminModel addItemSubType)
        {
            /*if (ModelState.IsValid)
             * {*/
            try
            {
                var addModel = new ItemTypeSub
                {
                    ItemType    = addItemSubType.ItemSubType.ItemType,
                    SubTypeName = addItemSubType.ItemSubType.SubTypeName
                };

                var add = _products.AddItemSubType(addModel);

                return(Json(addItemSubType.Message = "Item Sub Type added!"));
            }

            catch { return(Json(addItemSubType.Message = "Adding Item Sub Type Failed!")); }

            /* }
             *
             * else { return Json(addItemSubType.Message = "Something went wrong!"); }*/

            /* return Json(addItemSubType);*/
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Index()
        {
            if (await CheckRole() == false)
            {
                return(NotFound());
            }

            var images = _imageService.GetAll();
            var g      = images.GroupBy(x => x.Album.Category.Name).Select(x => new ChartDataModel
            {
                Key   = x.Key,
                Value = x.Count()
            }).OrderByDescending(x => x.Value);

            var users = _userService.GetAll();
            var g2    = users.GroupBy(x => new DateTime(x.DateCreated.Value.Year, x.DateCreated.Value.Month, 1)).Select(
                x => new
            {
                x.Key,
                Value = x.Count()
            }).OrderByDescending(x => x.Key).Select(x => new ChartDataModel
            {
                Key   = x.Key.ToString("Y"),
                Value = x.Value
            });

            var model = new AdminModel
            {
                ImagesChartData = g.Take(10).ToList(),
                UsersChartData  = g2.Take(10).ToList()
            };

            return(View(model));
        }
        public override string[] GetRolesForUser(string username)
        {
            var adminobj = new AdminModel();
            var roleName = adminobj.GetRole(username);

            return(new[] { roleName });
        }
        public JsonResult AddItem([FromBody] AdminModel addItem)
        {
            /* if(ModelState.IsValid)
             * {*/
            try
            {
                var list = new List <string>();
                list = addItem.ImageUrls.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();

                List <ImageUrls> imgUrl = new List <ImageUrls>();

                foreach (var var in list)
                {
                    imgUrl.Add(new ImageUrls
                    {
                        Url = var
                    });
                }

                var item = new Items
                {
                    Availability = addItem.Availibility,
                    Price        = addItem.Price,
                    Discount     = addItem.Discount,
                    ManuModel    = addItem.Manufacturer,
                    Model        = addItem.Model,
                    ImageUrls    = imgUrl,
                    Color        = addItem.Color,
                    ItemTypeSub  = new ItemTypeSub {
                        Id = addItem.ItemSubType.Id
                    }
                };

                var model = new Model
                {
                    ItemDepartment = addItem.ItemDepartment,
                    Name           = addItem.ModelName,
                    SpecsId        = addItem.Specs,
                    TypeId         = addItem.ItemType
                };

                var spec = new Specs
                {
                    Description   = addItem.Specs.Description,
                    Specification = addItem.Specs.Specification
                };

                var addItems = _products.AddItem(item, spec, model);

                return(Json(addItem.Message = "Item added!"));;
            }
            catch { return(Json(addItem.Message = "Adding item failed!")); }

            /*}
             *
             * else { return Json(addItem.Message = "Something went wrong!"); }*/

            /* return Json(addItem);*/
        }
Ejemplo n.º 8
0
        public List <AdminModel> GetEventType(string query = "")
        {
            var getAllEventsList = new List <AdminModel>();

            try
            {
                if (String.IsNullOrEmpty(query))
                {
                    var geteventsObj = (from e in g.EventTypes

                                        select new
                    {
                        e.EventTypes,
                        e.EventTypeID,
                    }).ToList();
                    foreach (var item in geteventsObj)
                    {
                        var searchModelObj = new AdminModel();


                        searchModelObj.EventType   = item.EventTypes;
                        searchModelObj.EventTypeID = item.EventTypeID;



                        getAllEventsList.Add(searchModelObj);
                    }
                }
                else
                {
                    var geteventsObj = (from e in g.EventTypes
                                        .Where(et => et.EventTypes.Contains(query))
                                        select new
                    {
                        e.EventTypes,
                        e.EventTypeID,
                    }).ToList();
                    foreach (var item in geteventsObj)
                    {
                        var searchModelObj = new AdminModel();


                        searchModelObj.EventType   = item.EventTypes;
                        searchModelObj.EventTypeID = item.EventTypeID;



                        getAllEventsList.Add(searchModelObj);
                    }
                }
            }


            catch (Exception ex)
            {
                string d = ex.Message;
            }
            return(getAllEventsList);
        }
Ejemplo n.º 9
0
 public void InsertData(AdminModel admin)
 {
     if (admin != null)
     {
         db.AdminModels.Add(admin);
         db.SaveChanges();
     }
 }
Ejemplo n.º 10
0
        public AdminModel Login(string name, string password)
        {
            Admin      admin      = serviceAdmin.CheckPassword(name, password);
            AdminModel adminModel = Mapper.Map <Admin, AdminModel>(admin);

            adminModel.RequestModels = GetRequests();
            return(adminModel);
        }
Ejemplo n.º 11
0
        public AdminModel GetAdminInfo()
        {
            AdminModel model = new AdminModel();

            model      = GlobalConfig.Connection.GetAdmin_ByUserId(User.Id);
            model.User = User;
            return(model);
        }
Ejemplo n.º 12
0
 public AdminController(IPersonalService personalService, ICorporateService corporateService, IPetService petService, IMainPageOptionsService mainPageOptionsService)
 {
     _personalService        = personalService;
     _corporateService       = corporateService;
     _petService             = petService;
     _mainPageOptionsService = mainPageOptionsService;
     model = new AdminModel();
 }
Ejemplo n.º 13
0
        public ActionResult Home()
        {
            AdminModel AdminModel = (AdminModel)TempData["admin"];

            AdminModel.DashboardModel = new DashboardModel();
            DBConnection.GetTonsPeriod(AdminModel.DashboardModel);
            return(View("~/Views/Administrator/AdminHome/AdminHome.cshtml", AdminModel));
        }
Ejemplo n.º 14
0
        public JsonResult GetUsersexpectadmin()
        {
            var model   = new AdminModel();
            var res     = model.GetAllUsers();
            var product = res.Where(item => (item.role_id.role_name != "Administrator" && item.role_id.role_name != "Manager"));

            return(Json(product, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AdminModel adminModel = db.Admins.Find(id);

            db.Admins.Remove(adminModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        public IActionResult Reopen(String id)
        {
            var model = new AdminModel();

            model.ReopenAccount(id);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 17
0
 public ActionResult Subject(AdminModel m)
 {
     if (DataAdminController.CheckUser(Session, m)) //没有用户信息就跳转到登陆
     {
         return(RedirectToAction("Index"));
     }
     return(View(m));
 }
        /// <summary>
        /// Get page of configuration values of the TCS (second tab).
        /// </summary>
        /// <returns></returns>
        public ActionResult TCSValueConfiguration()
        {
            AdminModel AdminModel = (AdminModel)TempData["admin"];

            AdminModel.ConfigurationModel = new ConfigurationViewModel();
            DBConnection.GetBenefitsValue(AdminModel.ConfigurationModel);
            return(View("~/Views/Administrator/Configuration/TEColonesConfig.cshtml", AdminModel));
        }
        public JsonResult GetReviews([FromBody] AdminModel item)
        {
            var reviews = _products.GetReveiwsByModelName(item.ModelName);

            GetReview.Reviews = reviews;

            return(Json(GetReview.Reviews));
        }
Ejemplo n.º 20
0
        public ActionResult Admin()
        {
            ViewBag.Ad = LoginName;
            AdminModel model = new AdminModel();

            model.Users = users.GetAll();
            return(View(model));
        }
Ejemplo n.º 21
0
 public ActionResult AddNoun(AdminModel model)
 {
     if(!String.IsNullOrEmpty(model.NewNoun))
     {
         _adminService.InsertNoun(new Noun {Word = model.NewNoun});
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 22
0
 public string InsertAdmin(AdminModel admin)
 {
     if (admin != null)
     {
         data.InsertData(admin);
     }
     return("Data Inserted Successfully");
 }
Ejemplo n.º 23
0
        public IActionResult Enable(String id)
        {
            var model = new AdminModel();

            model.EnableCategory(id);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 24
0
 public ActionResult AddAdjective(AdminModel model)
 {
     if (!String.IsNullOrEmpty(model.NewAdjective))
     {
         _adminService.InsertAdjective(new Adjective { Word = model.NewAdjective });
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 25
0
        public AdminViewModel(AdminModel adminModel, ProviderAdmin providerAdmin)
        {
            this.adminModel    = adminModel;
            this.providerAdmin = providerAdmin;

            BlockedAdminCommandModel   = new BlockedAdminCommand(this);
            UnBlockedAdminCommandModel = new UnBlockedAdminCommand(this);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the page of creating new combo promotions.
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateComboPromotion()
        {
            AdminModel AdminModel = (AdminModel)TempData["admin"];

            AdminModel.PromotionModel = new PromotionViewModel();
            DBConnection.GetMaterialType(AdminModel.PromotionModel);
            return(View("~/Views/Administrator/Promotion/CreateComboPromotion.cshtml", AdminModel));
        }
Ejemplo n.º 27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     user = Common.GetLoginAdmin(HttpContext.Current);
     // this.LoadReport();
     this.LoadPromo();
     this.LoadNews();
     this.LoadFeedback();
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Gets the page of viewing all the combo promotions created, retrieved from the database.
        /// </summary>
        /// <returns></returns>
        public ActionResult ViewComboPromotion()
        {
            AdminModel AdminModel = (AdminModel)TempData["admin"];

            AdminModel.PromotionModel = new PromotionViewModel();
            DBConnection.GetPromotion(AdminModel.PromotionModel, "combo");
            return(View("~/Views/Administrator/Promotion/ViewComboPromotion.cshtml", AdminModel));
        }
Ejemplo n.º 29
0
        public ActionResult ListOrder()
        {
            AdminModel model         = new AdminModel();
            var        bookTableList = entity.OrderTables.ToList();

            model.BookTableList = bookTableList;
            return(View("ListOrder", model));
        }
Ejemplo n.º 30
0
        public JsonResult GetAuthentication(string adminName, string adminPassword)
        {
            AdminModel admin = new AdminModel {
                Password = adminPassword, UserName = adminName
            };

            return(Json(queries.Authenticated(admin), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="model">数据实体</param>
        /// <returns></returns>
        public bool Update(AdminModel model)
        {
            var db  = base.DB;
            var cmd = db.GetSqlStringCommand(UpdateSql);

            BindParameters(db, cmd, model);
            return(db.ExecuteNonQuery(cmd) > 0 ? true : false);
        }
        //"Sede:CA Tonelada:120/Sede:CA Tonelada:150/Sede:CA Tonelada:180/Sede:CA Tonelada:190"
        #region MainViewTabsMethods
        /// <summary>
        /// Get page of configuration values of the materials.
        /// </summary>
        /// <returns></returns>
        public ActionResult MaterialValueConfiguration()
        {
            AdminModel AdminModel = (AdminModel)TempData["admin"];

            AdminModel.ConfigurationModel = new ConfigurationViewModel();
            DBConnection.GetMaterialTCSValue(AdminModel.ConfigurationModel);
            return(View("~/Views/Administrator/Configuration/MaterialConfig.cshtml", AdminModel));
        }
Ejemplo n.º 33
0
        public IActionResult Delete(String id)
        {
            var model = new AdminModel();

            model.DeleteAccount(id);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 34
0
        public int DeleteAdmin(AdminModel am)
        {
            int result = DaoUtilities.NO_CHANGES;

            ADMIN a = db.ADMIN.Find(am.UserId);

            if (a != null)
            {
                db.ADMIN.Remove(a);
                try
                {
                    int saveResult = db.SaveChanges();

                    if (saveResult == 1)
                        result = DaoUtilities.SAVE_SUCCESSFUL;
                }
                catch (DbUpdateConcurrencyException e)
                {
                    Console.WriteLine(e.GetBaseException().ToString());
                    result = DaoUtilities.UPDATE_CONCURRENCY_EXCEPTION;
                }
                catch (DbUpdateException e)
                {
                    Console.WriteLine(e.GetBaseException().ToString());
                    result = DaoUtilities.UPDATE_EXCEPTION;
                }
                catch (DbEntityValidationException e)
                {
                    Console.WriteLine(e.GetBaseException().ToString());
                    result = DaoUtilities.ENTITY_VALIDATION_EXCEPTION;
                }
                catch (NotSupportedException e)
                {
                    Console.WriteLine(e.GetBaseException().ToString());
                    result = DaoUtilities.UNSUPPORTED_EXCEPTION;
                }
                catch (ObjectDisposedException e)
                {
                    Console.WriteLine(e.GetBaseException().ToString());
                    result = DaoUtilities.DISPOSED_EXCEPTION;
                }
                catch (InvalidOperationException e)
                {
                    Console.WriteLine(e.GetBaseException().ToString());
                    result = DaoUtilities.INVALID_OPERATION_EXCEPTION;
                }
            }
            return result;
        }
Ejemplo n.º 35
0
 public ActionResult AddAdministrator(AdminModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _accounts.CreateUser(model.NewUser.FirstName, model.NewUser.LastName, model.NewUser.Email, model.NewUser.Password, false);
             return RedirectToAction("Index");
         }
         catch(ArgumentException e)
         {
             ModelState.AddModelError("", e.Message);
         }
     }
     return View("Index", model);
 }
Ejemplo n.º 36
0
        private void defineUser()
        {
            switch (_authModel.CurrentUserType)
            {
                case UserTypes.Admin:
                {
                    _userModel = new AdminModel();
                    _authPresenter.showMessage("Вы вошли как админ епт");
                    _authPresenter.hide();
                    _userPresenter = new AdminPresenter(_workerView,_userModel);
                    break;
                }

                default:
                {
                    _authPresenter.showMessage("Ошибка авторизации!");
                    break;
                }
            }
        }
        /// <summary>
        /// Convert an admin from the database to an AdminModel
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public AdminModel ConvertAdminToAdminModel(ADMIN a)
        {
            USER1 u = db.USER1.Find(a.ADMIN_ID);

            AdminModel am = new AdminModel();

            if (a != null && u != null)
            {
                am.UserId = u.USER_ID;
                am.Password = u.USER_PASSWORD;
                am.FirstName = u.USER_FIRSTNAME;
                am.LastName = u.USER_LASTNAME;
                am.Adress1 = u.USER_ADR1;
                am.Adress2 = u.USER_ADR2;
                am.PC = u.USER_PC;
                am.Town = u.USER_TOWN;
                am.Phone = u.USER_PHONE;
                am.Mail = u.USER_MAIL;
            }
            else
                am = null;

            return am;
        }
Ejemplo n.º 38
0
 public AdminModel Build()
 {
     var model = new AdminModel();
     model.menu = BuildMenu();
     return model;
 }