public async Task <IHttpActionResult> PutServiceRequest(int id, ServiceRequest serviceRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != serviceRequest.id)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceRequestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PutCustomer(int id, Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.customerID)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public async Task <ActionResult> Create([Bind(Include = "jobCode,jobDescription,freelancerID,hourlyRate,baseRate,imageURL")] Job job)
        {
            //string fileName, extension;

            if (ModelState.IsValid)
            {
                try
                {
                    //fileName = Path.GetFileNameWithoutExtension(job.imageFile.FileName);
                    //extension = Path.GetExtension(job.imageFile.FileName);
                    //fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    //job.imageURL = "~/Images/" + fileName;
                    //fileName = Path.Combine(Server.MapPath("~/Image/"), fileName);
                    //job.imageFile.SaveAs(fileName);

                    db.Jobs.Add(job);
                    await db.SaveChangesAsync();

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

            ViewBag.freelancerID = new SelectList(db.FreelancerClients, "freelancerID", "freelancerName", job.freelancerID);
            return(View(job));
        }
        public async Task <ActionResult> Create([Bind(Include = "freelancerID,freelancerName,freelancerSurname,freelancerEmail,freelancerPhone,freelancerAddress,city,postalCode,freelancerWebsite,occupation,bio,imageURL, ImageFile")] FreelancerClient freelancerClient)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string fileName  = Path.GetFileNameWithoutExtension(freelancerClient.ImageFile.FileName);
                    string extension = Path.GetExtension(freelancerClient.ImageFile.FileName);
                    fileName = fileName + DateTime.Now.ToString("yymmssff") + extension;
                    freelancerClient.imageURL = "~/images/" + fileName;

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

                    db.FreelancerClients.Add(freelancerClient);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Create", "Users", new { newUserId = freelancerClient.freelancerID, role = "member" }));
                }
                catch (Exception Ex)
                {
                    ViewBag.ErrorMessage = Ex.Message;
                    return(View("Error"));
                }
            }

            ViewBag.occupation = new SelectList(db.Departments, "departmentCode", "departmentName", freelancerClient.occupation);
            return(View(freelancerClient));
        }
예제 #5
0
        public async Task <ActionResult> Create([Bind(Include = "departmentCode,departmentName")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
예제 #6
0
        public async Task <ActionResult> Create([Bind(Include = "customerID,customerName,customerSurname,customerAddress,customerCity,customerEmail,customerPhone,postalCode, ImageFile")] Customer customer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Customers.Add(customer);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Create", "Users", new { newUserId = customer.customerID, role = "user" }));
                }
            } catch (Exception Ex)
            {
                ViewBag.ErrorMessage = Ex.Message;
                return(View("Error"));
            }

            return(View(customer));
        }
        public async Task <ActionResult> Create([Bind(Include = "id,userID,userName,userPassword,emailStatus,registerDate,userRole,freelancerID")] User user, int newUserId, string role, FormCollection form)
        {
            string password = FormsAuthentication.HashPasswordForStoringInConfigFile(form["password"], "SHA1");


            try
            {
                user.registerDate = DateTime.Now;
                user.emailStatus  = false;
                user.userPassword = password;

                if (role == "user")
                {
                    //db.Customers.Find(newUserId);
                    user.customerId = newUserId;
                    user.userRole   = "user";
                }
                else if (role == "member")
                {
                    user.freelancerID = newUserId;
                    user.userRole     = "member";
                }

                db.Users.Add(user);
                await db.SaveChangesAsync();

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


            ViewBag.userID       = new SelectList(db.Customers, "customerID", "customerName", user.customerId);
            ViewBag.freelancerID = new SelectList(db.FreelancerClients, "freelancerID", "freelancerName", user.freelancerID);
            return(View(user));
        }