Beispiel #1
0
        //[ValidateAntiForgeryToken]
        //public ActionResult Create([Bind(Include = "jobCode,jobDescription,freelancerID,hourlyRate,baseRate,imageURL")]Job newJob)
        public ActionResult Create(Job newJob)
        {
            int id = Convert.ToInt32(Session["memberId"].ToString());

            string fileName  = Path.GetFileNameWithoutExtension(newJob.ImageFile.FileName);
            string extension = Path.GetExtension(newJob.ImageFile.FileName);

            fileName        = fileName + DateTime.Now.ToString("yymmssff") + extension;
            newJob.imageURL = "~/images/" + fileName;

            fileName = Path.Combine(Server.MapPath("~/images/"), fileName);
            newJob.ImageFile.SaveAs(fileName);

            try
            {
                if (ModelState.IsValid)
                {
                    newJob.freelancerID = id;
                    newJob.datePosted   = DateTime.Now;
                    db.Jobs.Add(newJob);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }catch (Exception Ex)
            {
                ViewBag.ErrorMessage = Ex.Message;

                return(View("Error"));
            }
            return(View());
        }
Beispiel #2
0
        public ActionResult ApproveBooking(int?id)
        {
            if (id == null)
            {
                return(Content("ID is null"));
            }

            try
            {
                ServiceRequest service = db.ServiceRequests.Find(id);

                if (service != null)
                {
                    service.verified = true;

                    db.Entry(service).State = EntityState.Modified;
                    db.SaveChanges();
                }
            } catch (Exception Ex)
            {
                ViewBag.ErrorMessage = Ex.Message;
                return(View("Error"));
            }
            return(RedirectToAction("Index", "MemberHome"));
        }
Beispiel #3
0
        public ActionResult ServiceRequest([Bind(Include = "serviceDescription, Category, deliveryDate, budget")] ServiceRequest request, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    request.deliveryDate = Convert.ToDateTime(form["deliveryDate"]);
                    request.requestDate  = DateTime.Now;
                    request.verified     = false;
                    request.customerID   = Convert.ToInt32(Session["memberId"].ToString());
                    request.verified     = false;
                    request.isDeleted    = false;

                    db.ServiceRequests.Add(request);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch (Exception Ex)
                {
                    ViewBag.ErrorMessage = Ex.Message;
                    return(View("Error"));
                }
            }

            ViewBag.Category = new SelectList(db.Departments, "departmentCode", "departmentName");
            return(View());
        }
        public ActionResult Edit([Bind(Include = "freelancerID,freelancerName,freelancerSurname,freelancerEmail,freelancerPhone,freelancerAddress,city,postalCode,freelancerWebsite,occupation,bio,imageURL")] FreelancerClient freelancer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    freelancer.occupation      = "CRP";
                    db.Entry(freelancer).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index", "MemberHome"));
                }
            } catch (Exception Ex)
            {
                ViewBag.ErrorMessage = Ex.Message;
                return(View("Error"));
            }
            return(Content("There's a error in this method"));
        }