コード例 #1
0
        public ActionResult Index(QRCModel ObjUserModel)
        {
            DARModel objDAR = null; long LocId = 0;

            eTracLoginModel ObjLoginModel = null;

            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
            }


            if (Session["eTrac_SelectedDasboardLocationID"] != null)
            {
                LocId = (long)Session["eTrac_SelectedDasboardLocationID"];
            }
            try
            {
                //if (ModelState.IsValid)
                //{

                if (ObjUserModel != null && ObjUserModel.UserModel != null) //&& ObjUserModel.UserModel.UserId == 0
                {
                    objDAR            = new DARModel();
                    objDAR.LocationId = ObjLoginModel.LocationID;
                    objDAR.UserId     = ObjLoginModel.UserId;
                    objDAR.CreatedBy  = ObjLoginModel.UserId;
                    objDAR.CreatedOn  = DateTime.UtcNow;


                    if (ObjUserModel.UserModel.UserId == 0)
                    {
                        #region password

                        if (!String.IsNullOrEmpty(ObjUserModel.UserModel.Password))
                        {
                            ObjUserModel.UserModel.Password = Cryptography.GetEncryptedData(ObjUserModel.UserModel.Password, true);
                        }
                        #endregion password

                        ObjUserModel.UserModel.CreatedBy     = ObjLoginModel.UserId;
                        ObjUserModel.UserModel.CreatedDate   = DateTime.UtcNow;
                        ObjUserModel.UserModel.IsDeleted     = false;
                        ObjUserModel.UserModel.IdleTimeLimit = DateTime.UtcNow.SetTime(0, 30, 0, 0);//Added By Bhushan on 07/06/2015 for by deafult IDLE Time set

                        objDAR.TaskType        = (long)TaskTypeCategory.UserCreation;
                        objDAR.ActivityDetails = DarMessage.NewEmployeeCreatedDar(ObjLoginModel.Location);
                    }
                    else
                    {
                        ObjUserModel.UserModel.ModifiedBy   = ObjLoginModel.UserId;
                        ObjUserModel.UserModel.ModifiedDate = DateTime.UtcNow;
                        ObjUserModel.UserModel.IsDeleted    = false;
                        if (!String.IsNullOrEmpty(ObjUserModel.UserModel.Password))
                        {
                            ObjUserModel.UserModel.Password = Cryptography.GetEncryptedData(ObjUserModel.UserModel.Password, true);
                        }

                        objDAR.TaskType        = (long)TaskTypeCategory.UserUpdate;
                        objDAR.ActivityDetails = DarMessage.EmployeeUpdatedDar(ObjLoginModel.Location);
                    }

                    if (ObjUserModel.UserModel.ProfileImage != null)
                    {
                        string       ImageName        = ObjLoginModel.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + ObjUserModel.UserModel.ProfileImage.FileName.ToString();
                        CommonHelper obj_CommonHelper = new CommonHelper();
                        obj_CommonHelper.UploadImage(ObjUserModel.UserModel.ProfileImage, Server.MapPath(ConfigurationManager.AppSettings["ProfilePicPath"]), ImageName);
                        ObjUserModel.UserModel.ProfileImageFile = ImageName;
                    }
                    long QRCID = 0;

                    Result result = _IClientManager.SaveClient(ObjUserModel.UserModel, out QRCID, true, objDAR, LocId, ObjLoginModel.UserId, "");

                    if (result == Result.Completed)
                    {
                        var abc = _ICommonMethod.GetLocationDetailsById(ObjLoginModel.LocationID);

                        EmailHelper objEmailHelper = new EmailHelper();
                        objEmailHelper.emailid      = ObjUserModel.UserModel.UserEmail;
                        objEmailHelper.LocationName = abc.LocationName;
                        objEmailHelper.LocAddress   = ObjUserModel.UserModel.Address.Address1; // here locAddress means user Address
                        objEmailHelper.UserName     = ObjUserModel.UserModel.AlternateEmail;
                        objEmailHelper.UserType     = ObjUserModel.UserModel.UserType;
                        objEmailHelper.FirstName    = ObjUserModel.UserModel.FirstName;
                        objEmailHelper.LastName     = ObjUserModel.UserModel.LastName;
                        objEmailHelper.Password     = Cryptography.GetDecryptedData(ObjUserModel.UserModel.Password, true);
                        objEmailHelper.MailType     = "CreateNewUser";

                        HostingPrefix = HostingPrefix + "Manager/Employee?usr="******"ITAdministrator");//return RedirectToAction("Create ", "GlobalAdmin");
                        ObjUserModel = _ICommonMethod.LoadInvitedUser(string.Empty);
                    }
                    else if (result == Result.DuplicateRecord)
                    {
                        ViewBag.Message           = CommonMessage.DuplicateRecordEmailIdMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Info; // store the message for successful in tempdata to display in view.
                    }
                    else if (result == Result.UpdatedSuccessfully)
                    {
                        ViewBag.Message           = CommonMessage.UpdateSuccessMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;// store the message for successful in tempdata to display in view.
                        ModelState.Clear();
                        //return RedirectToAction("index", "GlobalAdmin");
                        ObjUserModel = _ICommonMethod.LoadInvitedUser(string.Empty);
                    }
                    else
                    {
                        ViewBag.Message           = CommonMessage.FailureMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view.
                    }
                }
                else
                {
                    ViewBag.Message = CommonMessage.InvalidEntry();
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message           = ex.Message;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
            }
            finally
            {
                ViewBag.Country = _ICommonMethod.GetAllcountries();

                ViewBag.JobTitleList = _ICommonMethod.GetGlobalCodeData("UserJobTitle");
                ViewBag.LocationList = _IGlobalAdmin.GetAllLocationNew();

                //System.Data.Entity.Core.Objects.ObjectParameter paramTotalRecords = new System.Data.Entity.Core.Objects.ObjectParameter("TotalRecords", typeof(int));
                //ObjUserModel.JobTitleList = _ICommonMethod.GetGlobalCodeData("JOBTITLE");
                //ObjUserModel.LocationList = _IGlobalAdmin.GetAllLocationList(0, "GetAllLocation", 1, 10000, "LocationName", "desc", "", paramTotalRecords);
                //paramTotalRecords = null;
            }

            ViewBag.UpdateMode = false;
            //ObjUserModel.UserModel = _IClientManager.GetClientByID(ObjUserModel.UserModel.UserId, "GetUserByID", null, null, null, null, null);


            //1	USERTYPE	Global Admin
            //2	USERTYPE	Manager
            //3	USERTYPE	Employee
            //4	USERTYPE	Client
            //5	USERTYPE	IT Administrator
            //6	USERTYPE	Administrator
            //137	USERTYPE	Vendor User
            //138	USERTYPE	Guest User
            //switch (ObjLoginModel.UserRoleId)
            //{
            //    case 1:
            //        {
            //            //return View("", ObjUserModel);
            //            return RedirectToAction("Index", "GlobalAdmin");
            //        } break;
            //    case 2:
            //        { } break;
            //    case 3:
            //        { } break;
            //    case 4:
            //        { } break;
            //    case 5:
            //        { } break;
            //    case 6:
            //        { } break;
            //}

            return(View("Employee", ObjUserModel));
        }