Beispiel #1
0
        public ActionResult Create([Bind(Prefix = "ID")] int RPASID = 0)
        {
            ViewBag.Title = "Create Pilot";
            if (exLogic.User.hasAccess("PILOTS.CREATE") ||
                exLogic.User.hasAccess("ORGANIZATION.ADMIN"))
            {
                //allow access
            }
            else
            {
                return(RedirectToAction("NoAccess", "Home"));
            }

            ViewBag.IsPassowrdRequired = true;
            PilotCreateModel EPASValues = new PilotCreateModel();

            if (RPASID != 0)
            {
                ViewBag.RPASid             = RPASID;
                ViewBag.IsPassowrdRequired = false;
                var RPASoList = (from p in db.MSTR_RPAS_User where p.RpasId == RPASID select p).ToList();
                EPASValues.FirstName  = RPASoList[0].Name;
                EPASValues.CountryId  = Convert.ToInt16(RPASoList[0].NationalityId);
                EPASValues.EmiratesID = RPASoList[0].EmiratesId;
                EPASValues.EmailId    = RPASoList[0].EmailId;
                EPASValues.MobileNo   = RPASoList[0].MobileNo;
            }

            return(View(EPASValues));
        }
Beispiel #2
0
        public ActionResult Create(PilotCreateModel UserModel, int ID = 0)
        {
            if (exLogic.User.hasAccess("PILOTS.CREATE") ||
                exLogic.User.hasAccess("ORGANIZATION.ADMIN"))
            {
                //allow access
            }
            else
            {
                return(RedirectToAction("NoAccess", "Home"));
            }

            if (ModelState.IsValid)
            {
                if (exLogic.User.UserExist(UserModel.UserName) > 0)
                {
                    ModelState.AddModelError("User.UserName", "This Pilot already exists.");
                }
                if (exLogic.User.EmailExist(UserModel.EmailId) > 0)
                {
                    ModelState.AddModelError("User.EmailId", "This email id already exists.");
                }
            }


            if (ModelState.IsValid)
            {
                int    AccountID = Util.getAccountID();
                String SQL       = "insert into MSTR_User(\n" +
                                   "  UserName,\n" +
                                   "  Password,\n" +
                                   "  FirstName,\n" +
                                   "  MiddleName,\n" +
                                   "  LastName,\n" +
                                   "  CreatedBy,\n" +
                                   "  UserProfileId,\n" +
                                   "  Remarks,\n" +
                                   "  MobileNo,\n" +
                                   "  OfficeNo,\n" +
                                   "  HomeNo,\n" +
                                   "  EmailId,\n" +
                                   "  CountryId,\n" +
                                   "  IsActive,\n" +
                                   "  CreatedOn,\n" +
                                   "  AccountId,\n" +
                                   "  IsPilot, \n" +
                                   "  PhotoUrl,\n" +
                                   "  Dashboard,\n" +
                                   "  RPASPermitNo,\n" +
                                   "  PermitCategory,\n" +
                                   "  ContactAddress,\n" +
                                   "  RegRPASSerialNo,\n" +
                                   "  EmiratesID,\n" +
                                   "  Nationality\n" +
                                   ") values(\n" +
                                   "  '" + Util.FirstLetterToUpper(UserModel.UserName) + "',\n" +
                                   "  '" + Util.MD5(UserModel.Password) + "',\n" +
                                   "  '" + Util.FirstLetterToUpper(UserModel.FirstName) + "',\n" +
                                   "  '" + Util.FirstLetterToUpper(UserModel.MiddleName) + "',\n" +
                                   "  '" + Util.FirstLetterToUpper(UserModel.LastName) + "',\n" +
                                   "   " + Util.getLoginUserID() + ",\n" +
                                   "  '" + Util.getPilotProfileID(AccountID) + "' ,\n" +
                                   "  '" + UserModel.Remarks + "',\n" +
                                   "  '" + UserModel.MobileNo + "',\n" +
                                   "  '" + UserModel.OfficeNo + "',\n" +
                                   "  '" + UserModel.HomeNo + "',\n" +
                                   "  '" + UserModel.EmailId + "',\n" +
                                   "   " + Util.toInt(UserModel.CountryId) + ",\n" +
                                   "  1,\n" +
                                   "  GETDATE(),\n" +
                                   "  " + AccountID + ",\n" +
                                   "  1,\n" +
                                   "  '" + UserModel.PhotoUrl + "',\n" +
                                   "  '" + Util.getDashboard() + "',\n" +
                                   "  '" + UserModel.RPASPermitNo + "',\n" +
                                   "  '" + UserModel.PermitCategory + "',\n" +
                                   "  '" + UserModel.ContactAddress + "',\n" +
                                   "  '" + UserModel.RegRPASSerialNo + "',\n" +
                                   "  '" + UserModel.EmiratesID + "',\n" +
                                   "  '" + UserModel.Nationality + "'\n" +
                                   ")";
                //inserting pilot information to the pilot table
                int id = Util.InsertSQL(SQL);

                SQL = "insert into MSTR_User_Pilot(\n" +
                      "  UserId,\n" +
                      "  PassportNo,\n" +
                      "  DateOfExpiry,\n" +
                      "  Department,\n" +
                      "  EmiratesId,\n" +
                      "  Title\n" +
                      ") values(\n" +
                      "  '" + id + "',\n" +
                      "  '" + UserModel.PassportNo + "',\n" +
                      "  '" + UserModel.DateOfExpiry + "',\n" +
                      "  '" + UserModel.Department + "',\n" +
                      "  '" + UserModel.EmiratesID + "',\n" +
                      "  '" + UserModel.Department + "'\n)";
                int Pid = Util.InsertSQL(SQL);


                MovePhto(UserModel.PhotoUrl, id);
                if (exLogic.User.hasAccess("ORGANIZATION.ADMIN"))
                {
                    UpdateLinkedDrone(UserModel.LinkedDroneID, id);
                }
                return(RedirectToAction("PilotDetail", "Pilot", new { ID = id }));
            }

            return(View(UserModel));
        }//Create() HTTPPost