public ActionResult Clientreg(ClientRegistration reg)
 {
     if (ModelState.IsValid)
     {
         using (CargoTrackerDbContext db = new CargoTrackerDbContext())
         {
             var result = db.ClientRegistrations.Add(reg);
             if (result == null)
             {
                 return(View());
             }
             else
             {
                 db.SaveChanges();
             }
             TrackInfoUpdate update = new TrackInfoUpdate();
             update.TrackingId = result.TrackingId;
             update.CreatedOn  = result.CreatedOn;
             update.Location   = result.ShippersCountryName;
             update.Status     = result.Status;
             db.UpdateTrackerInformations.Add(update);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = reg.ShippersFirstName + " " + reg.ShippersLastName + " " + "was successfully Registered";
     }
     return(View());
 }
        public ActionResult Delete(int?id)
        {
            if (!AuthenticateUser())
            {
                return(RedirectToAction("Index"));
            }

            if (id == null || id == 0)
            {
                return(RedirectToAction("manageusers"));
            }

            using (CargoTrackerDbContext db = new CargoTrackerDbContext())
            {
                var result = db.ClientRegistrations.Find(id);
                if (result == null)
                {
                    return(RedirectToAction("manageusers"));
                }
                string TrackingId = result.TrackingId;
                var    data       = db.ClientRegistrations.Remove(result);
                db.SaveChanges();
                if (data == null)
                {
                    var result2 = db.UpdateTrackerInformations.Find(TrackingId);
                    db.UpdateTrackerInformations.Remove(result2);
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("manageusers"));
        }
Пример #3
0
        public ActionResult Contact(TrackContactUs contactUs)
        {
            if (ModelState.IsValid)
            {
                using (CargoTrackerDbContext db = new CargoTrackerDbContext())
                {
                    db.Contacts.Add(contactUs);
                    db.SaveChanges();
                }
                ModelState.Clear();
                ViewBag.Message = contactUs.FullName + " " + "Request was successfully sent";
                return(View());
            }

            return(View());
        }
Пример #4
0
 public ActionResult Feedback(TrackContactUs track)
 {
     if (ModelState.IsValid)
     {
         using (CargoTrackerDbContext db = new CargoTrackerDbContext())
         {
             var result = db.Contacts.Add(track);
             if (result == null)
             {
                 return(View());
             }
             db.SaveChanges();
         }
         ViewBag.Message = "Message sent Successfully";
         ModelState.Clear();
     }
     return(View());
 }
        public ActionResult clientupdate(ClientRegistration reg)
        {
            if (reg.UserId == 0)
            {
                return(RedirectToAction("inbox"));
            }

            if (ModelState.IsValid)
            {
                using (CargoTrackerDbContext db = new CargoTrackerDbContext())
                {
                    var result = db.ClientRegistrations.SingleOrDefault(u => u.UserId == reg.UserId);
                    if (result == null)
                    {
                        return(RedirectToAction("Manageusers"));
                    }

                    result.ShippersFirstName    = reg.ShippersFirstName;
                    result.ShippersLastName     = reg.ShippersLastName;
                    result.ReceiversFirstName   = reg.ReceiversFirstName;
                    result.ReceiversLastName    = reg.ReceiversLastName;
                    result.ReceiversCountryName = reg.ReceiversCountryName;
                    result.ReceiversEmail       = reg.ReceiversEmail;
                    result.ReceiversPhone       = reg.ReceiversPhone;
                    result.ShippersPhone        = reg.ShippersPhone;
                    result.Status           = reg.ShippersPhone;
                    result.TrackingId       = reg.TrackingId;
                    result.weight           = reg.weight;
                    result.TotalFreight     = reg.TotalFreight;
                    result.ReceiversAddress = reg.ReceiversAddress;
                    result.BookingMode      = reg.BookingMode;
                    result.Comment          = reg.Comment;
                    result.CreatedOn        = reg.CreatedOn;
                    result.Invoice          = reg.Invoice;
                    result.PickTime         = reg.PickTime;
                    result.PickupDate       = reg.PickupDate;
                    result.DeliveryMode     = reg.DeliveryMode;
                    result.Description      = reg.Description;
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Manageusers"));
        }
Пример #6
0
 public ActionResult TrackShipment(string TrackingId)
 {
     if (ModelState.IsValid)
     {
         using (CargoTrackerDbContext db = new CargoTrackerDbContext())
         {
             var result  = db.ClientRegistrations.SingleOrDefault(u => u.TrackingId == TrackingId);
             var result2 = db.UpdateTrackerInformations.SingleOrDefault(u => u.TrackingId == TrackingId);
             if (result == null)
             {
                 ViewBag.Message = "Invalid User Tracker Id";
                 return(View());
             }
             db.SaveChanges();
             Session["User"]  = result;
             Session["User2"] = result2;
         }
     }
     return(RedirectToAction("Account"));
 }
 public ActionResult Createtrackinfo(string TrackingId, string Location, string Status)
 {
     if (ModelState.IsValid)
     {
         using (CargoTrackerDbContext db = new CargoTrackerDbContext())
         {
             var result = db.UpdateTrackerInformations.SingleOrDefault(U => U.TrackingId == TrackingId);
             if (result == null)
             {
                 return(View());
             }
             result.Location  = Location;
             result.Status    = Status;
             result.CreatedOn = DateTime.Now;
             db.SaveChanges();
         }
         ViewBag.Message = "Successful Update";
         ModelState.Clear();
     }
     return(View());
 }
 public ActionResult AdminRegistration(AdminLogin login)
 {
     if (ModelState.IsValid)
     {
         using (CargoTrackerDbContext db = new CargoTrackerDbContext())
         {
             if (login.Password != login.ConfirmPassword)
             {
                 ViewBag.Message = "Both password must be the same";
                 return(View());
             }
             var result = db.AdminLogins.Add(login);
             if (result == null)
             {
                 return(View());
             }
             db.SaveChanges();
         }
         ViewBag.Message = "Successfully Registered";
         ModelState.Clear();
     }
     return(View());
 }