public ViewResult Notifications()
        {
            ViewBag.Title = Constant.NOTIFICATIONS;

            var ldnvm   = new ListDepreciationNotificationViewModel();
            var depnObj = _repDepreciation.GetAnnualDepreciationNotifications()
                          .Select(x => new DepreciationNotificationViewModel
            {
                AssetName           = x.AssetName,
                PurchaseNo          = x.PurchaseNo,
                AssetPurchaseId     = x.AssetPurchaseId,
                PurchaseType        = x.PurchaseType,
                PurchasedDateString = x.PurchasedDate.ToString("yyyy/MM/dd"),
                PurchasedPrice      = Decimal.Parse(x.PurchasedPrice.ToString("G29")),
                DepreciationRate    = Decimal.Parse(x.DepreciationRate.ToString("G29")),
                DepreciationType    = x.DepreciationType.ToUpper(),
                //AssetValue = Decimal.Parse(GetCurrentAssetValue(x.PurchasedPrice,
                //                x.PurchasedDate,
                //                x.DepreciationRate,
                //                x.DepreciationType).ToString("#.##")) //Calculate Asset Value

                AssetValue = Decimal.Parse(CurrentItemValue.GetCurrentValue(x.AssetPurchaseId).ToString("#.##"))
            }).Skip(0).Take(5);

            ldnvm.CountDepreciationNotification = _repDepreciation.GetAnnualDepreciationNotifications().Count();

            if (depnObj != null)
            {
                ldnvm.ListDepreciationNotification = depnObj.ToList();
            }



            return(View(ldnvm));
        }
Esempio n. 2
0
        public ActionResult Login(UserLoginViewModel model, string returnUrl)
        {
            ViewBag.Title = Constant.ADMIN_LOGIN;

            try
            {
                if (ModelState.IsValid)
                {
                    var    provider = Membership.Provider;
                    string name     = provider.ApplicationName; // Get the application name here

                    //if (Membership.GetUser("rabi.shrestha").IsLockedOut)
                    //    Membership.GetUser("rabi.shrestha").UnlockUser();

                    var username = Membership.GetAllUsers().Cast <MembershipUser>().Select(x => new { x.Email, x.UserName }).AsQueryable();

                    bool validated = Membership.ValidateUser(model.Username, model.Password);

                    var getIRASPermission = _repIRASPermission.GetIRASPermission();

                    //IRAS_Assets_Manager
                    var irasAssetManager = getIRASPermission.Where(x => x.RoleID == 44);

                    //IRAS_Assets_Users
                    var irasAssetUser = getIRASPermission.Where(x => x.RoleID == 43);

                    var intranetUserId = _repIRASPermission.GetUserIDFromIntranet()
                                         .Where(x => x.Username == model.Username)
                                         .SingleOrDefault().UserID;

                    if (validated)
                    {
                        SessionHelper.UserId    = intranetUserId;
                        SessionHelper.Username  = model.Username;
                        SessionHelper.UserEmail = username.Where(x => x.UserName == model.Username)
                                                  .SingleOrDefault().Email;
                        SessionHelper.UserImage  = model.Image;
                        SessionHelper.UserTypeId = (long)_repIRASPermission.GetIntranetUserType()
                                                   .Where(x => x.IntranetUserId == intranetUserId)
                                                   .SingleOrDefault().UserTypeId;
                        SessionHelper.UserTypeName = _repIRASPermission.GetIntranetUserType()
                                                     .Where(x => x.IntranetUserId == intranetUserId)
                                                     .SingleOrDefault().UserTypeName;

                        var depnObj = _repDepreciation.GetAnnualDepreciationNotifications();

                        if (depnObj != null)
                        {
                            SessionHelper.NotificationCount = _repDepreciation.GetAnnualDepreciationNotifications().Count();
                            SessionHelper.TopNotification   = depnObj.ToList();
                        }

                        return(RedirectToAction("Dashboard", "Home", new { area = "" }));
                    }
                    ModelState.AddModelError("Password", "The user name or password provided is incorrect.");
                }
                return(View(model));
            }
            catch (IOException e)
            {
                // Extract some information from this exception, and then
                // throw it to the parent method.
                if (e.Source != null)
                {
                    Console.WriteLine("IOException source: {0}", e.Source);
                    throw;
                }
            }

            return(View(model));
        }