예제 #1
0
 public ActionResult Login(LoginViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         if (!(string.IsNullOrEmpty(viewModel.Email) || string.IsNullOrEmpty(viewModel.Password)))
         {
             LoginRepository objloginRep    = new LoginRepository();
             tblUserDetail   objuserdetails = new tblUserDetail();
             objuserdetails = objloginRep.GetUserForAuthentication(viewModel.Email);
             if (objuserdetails != null)
             {
                 string passwordHash = HashHelper.ComputeSaltedHash(viewModel.Password, objuserdetails.PasswordSalt);
                 if (string.Equals(passwordHash, objuserdetails.PasswordHash, StringComparison.Ordinal))// Validate User password;
                 {
                     SessionData.LoggedUserName = objuserdetails.UserName;
                     return(RedirectToAction("GetAllUnProcessedRecords", "RoboticsProcess"));
                 }
                 else
                 {
                     ViewBag.LoginMessage = "The Employee ID or password is incorrect";
                 }
             }
             else
             {
                 ViewBag.LoginMessage = "The Employee ID or password is incorrect";
             }
         }
     }
     return(View());
 }
예제 #2
0
 public tblUserDetail GetUserForAuthentication(string emailId)
 {
     using (RoboticDataEntities entity = new RoboticDataEntities())
     {
         tblUserDetail objtblUserDetail = new tblUserDetail();
         objtblUserDetail = entity.tblUserDetails.Where(q => q.Email.Trim().ToLower() == emailId.Trim().ToLower()).FirstOrDefault();
         return(objtblUserDetail);
     }
 }
        // POST api/UserDetails
        public HttpResponseMessage PosttblUserDetail(tblUserDetail tbluserdetail)
        {
            db.tblUserDetails.Add(tbluserdetail);
            db.SaveChanges();

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, tbluserdetail);

            response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = tbluserdetail.PK_UserID }));
            return(response);
        }
예제 #4
0
        public ActionResult AddOrEdit(int id = 0)
        {
            TempData["Success"] = null;
            UserDetail userDetailModel = new UserDetail();


            HttpResponseMessage cityListResponse = GlobalVariables.WebApiClient.GetAsync("City/GettblCities").Result;



            if (id == 0)
            {
                userDetailModel.DOB    = DateTime.Now;
                userDetailModel.Cities = new SelectList(cityListResponse.Content.ReadAsAsync <IEnumerable <prc_GetCity_Result> >().Result, "PK_CityID", "Name", 1);

                HttpResponseMessage suburbListResponse = GlobalVariables.WebApiClient.GetAsync("Suburbs/GetSuburb/1").Result;
                userDetailModel.Suburbs = new SelectList(Enumerable.Empty <prc_GetSuburb_Result>(), "PK_SuburbID", "Name", 1);
                return(View(userDetailModel));
            }
            else
            {
                HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("UserDetails/GettblUserDetails/" + id.ToString()).Result;

                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    return(View(userDetailModel));
                }

                tblUserDetail getUserDetails = new tblUserDetail();
                getUserDetails = response.Content.ReadAsAsync <tblUserDetail>().Result;

                userDetailModel.PK_UserID     = getUserDetails.PK_UserID;
                userDetailModel.Name          = getUserDetails.Name;
                userDetailModel.Surname       = getUserDetails.Surname;
                userDetailModel.StreetAddress = getUserDetails.StreetAddress;
                userDetailModel.PoCode        = getUserDetails.PoCode;
                userDetailModel.IDNumber      = getUserDetails.IDNumber;
                userDetailModel.ContactNumber = getUserDetails.ContactNumber.ToString();

                userDetailModel.DOB = getUserDetails.DOB;

                userDetailModel.Cities = new SelectList(cityListResponse.Content.ReadAsAsync <IEnumerable <prc_GetCity_Result> >().Result, "PK_CityID", "Name", getUserDetails.FK_CityID);

                HttpResponseMessage suburbListResponse = GlobalVariables.WebApiClient.GetAsync("Suburbs/GetSuburb/" + getUserDetails.FK_CityID.ToString()).Result;
                userDetailModel.Suburbs = new SelectList(suburbListResponse.Content.ReadAsAsync <IEnumerable <prc_GetSuburb_Result> >().Result, "PK_SuburbID", "Name", getUserDetails.FK_SuburbID);



                return(View(userDetailModel));
            }
        }
        public ActionResult AddUser(AddUser objUser)
        {
            try
            {
                string filename  = Path.GetFileNameWithoutExtension(objUser.ImageFile.FileName);
                string extension = Path.GetExtension(objUser.ImageFile.FileName);

                filename = filename + DateTime.Now.ToString("yymmssfff") + extension;

                var temp = filename;
                objUser.ProductImage = "~/UserImage/" + filename;

                filename = Path.Combine(Server.MapPath("~/UserImage/"), filename);
                objUser.ImageFile.SaveAs(filename);
                tblUserDetail objUd = new tblUserDetail();
                objUd.Photo    = temp;
                objUd.IsActive = true;
                string fname = objUser.FirstName;
                string mname = objUser.MiddleName;
                string lname = objUser.LastName;
                fname = fname.First().ToString().ToUpper() + fname.Substring(1);
                mname = mname.First().ToString().ToUpper() + mname.Substring(1);
                lname = lname.First().ToString().ToUpper() + lname.Substring(1);
                string name = fname + mname + lname;
                objUd.Name             = name;
                objUd.Pincode          = objUser.Pincode;
                objUd.State            = objUser.State;
                objUd.Email            = objUser.Email;
                objUd.CreditcardNumber = objUser.CreditCardNumber;
                objUd.Createddate      = DateTime.Now;
                objUd.Country          = objUser.Country;
                objUd.City             = objUser.City;
                objUd.AddressLine2     = objUser.AdresLine2;
                objUd.AddressLine1     = objUser.AdressLine1;
                db.tblUserDetails.Add(objUd);
                if (db.SaveChanges() > 0)
                {
                    TempData["msg"] = "Data Added Successfully!!!!!";
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception _Ex)
            {
                string message = _Ex.Message;
                return(RedirectToAction("Error", message));
            }
        }
예제 #6
0
        public ActionResult AddOrEdit(UserDetail userDetail)
        {
            tblUserDetail postUserDetails = new tblUserDetail();

            postUserDetails.PK_UserID     = userDetail.PK_UserID;
            postUserDetails.Name          = userDetail.Name;
            postUserDetails.Surname       = userDetail.Surname;
            postUserDetails.StreetAddress = userDetail.StreetAddress;
            postUserDetails.PoCode        = userDetail.PoCode;
            postUserDetails.IDNumber      = userDetail.IDNumber;
            postUserDetails.ContactNumber = int.Parse(userDetail.ContactNumber);
            postUserDetails.FK_CityID     = userDetail.SelectedCity.PK_CityID;
            postUserDetails.FK_SuburbID   = userDetail.SelectedSuburb.PK_SuburbID;
            postUserDetails.DOB           = userDetail.DOB.AddHours(1);

            string ID  = postUserDetails.IDNumber;
            string dob = postUserDetails.DOB.Year.ToString().Substring(2) + postUserDetails.DOB.Month.ToString("00") + postUserDetails.DOB.Day.ToString("00");

            if (ID.Contains(dob))
            {
                HttpResponseMessage response;
                if (userDetail.PK_UserID > 0)
                {
                    response = GlobalVariables.WebApiClient.PutAsJsonAsync("UserDetails/PuttblUserDetail/" + userDetail.PK_UserID.ToString(), postUserDetails).Result;
                }
                else
                {
                    response = GlobalVariables.WebApiClient.PostAsJsonAsync("UserDetails/PosttblUserDetail", postUserDetails).Result;
                }

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    TempData["Success"] = "Successfully Saved";
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Success"] = "ID failed to match date of birth";

                return(RedirectToAction("AddOrEdit/" + userDetail.PK_UserID.ToString()));
            }
        }
        // PUT api/UserDetails/5
        public HttpResponseMessage PuttblUserDetail(int id, tblUserDetail tbluserdetail)
        {
            if (id != tbluserdetail.PK_UserID)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.Entry(tbluserdetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        // DELETE api/UserDetails/5
        public HttpResponseMessage DeletetblUserDetail(int id)
        {
            tblUserDetail tbluserdetail = db.tblUserDetails.Find(id);

            if (tbluserdetail == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.tblUserDetails.Remove(tbluserdetail);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, tbluserdetail));
        }