public ActionResult Create([Bind(Include = "ScheduleId,ShipmentDate,FromLocation,ToLocation,Rate,EarliestDeparture,Status,VesselsID")] Schedule schedule)
        {
            if (ModelState.IsValid)
            {
                db.Schedules.Add(schedule);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(schedule));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "BookingId,Cargo,ContainerType,ScheduleId,UsersId")] ScheduleBooking scheduleBooking)
        {
            if (ModelState.IsValid)
            {
                db.ScheduleBookings.Add(scheduleBooking);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ScheduleId = new SelectList(db.Schedules, "ScheduleId", "FromLocation", scheduleBooking.ScheduleId);
            ViewBag.UsersId    = new SelectList(db.Users, "UsersId", "Username", scheduleBooking.UsersId);
            return(View(scheduleBooking));
        }
Пример #3
0
        public ActionResult Save(Vessel vessel)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (DBDDACEntities3 dc = new DBDDACEntities3())
                {
                    if (vessel.VesselsId > 0)
                    {
                        //Edit
                        var v = dc.Vessels.Where(a => a.VesselsId == vessel.VesselsId).FirstOrDefault();
                        if (v != null)
                        {
                            v.VesselName = vessel.VesselName;
                            v.Terminal   = vessel.Terminal;
                            v.Country    = vessel.Country;
                        }
                    }
                    else
                    {
                        //Save
                        dc.Vessels.Add(vessel);
                    }
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Пример #4
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                //update new pw if valid
                using (DBDDACEntities3 dc = new DBDDACEntities3())
                {
                    var user = dc.Users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password          = Crypto.Hash(model.NewPassword);
                        user.ResetPasswordCode = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New password updated Successfully";
                    }
                }
            }
            else
            {
                message = "Something Invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Пример #5
0
        public ActionResult ForgotPassword(string Email)
        {
            //Verify Email

            //Generate Reset Password Link

            //Send Email

            string message = "";

            using (DBDDACEntities3 dc = new DBDDACEntities3())
            {
                var account = dc.Users.Where(a => a.Email == Email).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    //unique identification number which is stored
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;

                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your email.";
                }
                else
                {
                    message = "Account not found";
                }
            }

            ViewBag.Message = message;
            return(View());
        }
Пример #6
0
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user)
        {
            bool   Status  = false;
            string message = "";

            //saving data
            //Model Validation
            if (ModelState.IsValid)
            {
                //Email is already existed
                var isExist = IsEmailAlreadyExisted(user.Email);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already existed");
                    return(View(user));
                }

                #region Generate Activation Code
                user.ActivationCode = Guid.NewGuid();
                #endregion

                #region Password Hashing
                user.Password        = Crypto.Hash(user.Password);
                user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword);
                #endregion

                user.IsEmailVerified = false;


                #region Save to Database
                using (DBDDACEntities3 dc = new DBDDACEntities3())
                {
                    dc.Users.Add(user);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(user.Email, user.ActivationCode.ToString());
                    message = "Registration Succeed, Account Activation link " +
                              "has been sent to your email: " + user.Email;
                    Status = true;
                }
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(user));
        }
        public ActionResult Book(Booking booking)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (DBDDACEntities3 dc = new DBDDACEntities3())
                {
                    dc.Bookings.Add(booking);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Пример #8
0
        public ActionResult DeleteVessel(int id)
        {
            bool status = false;

            using (DBDDACEntities3 dc = new DBDDACEntities3())
            {
                var v = dc.Vessels.Where(a => a.VesselsId == id).FirstOrDefault();
                if (v != null)
                {
                    dc.Vessels.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Пример #9
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (DBDDACEntities3 dc = new DBDDACEntities3())
            {
                dc.Configuration.ValidateOnSaveEnabled = false;
                var v = dc.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }