Exemplo n.º 1
0
        public ActionResult addPC(int?caseID, int?moboID, int?CPUID, int?RAMID, int?GPUID, int?coolerID, int?SSDID, int?FanID, int?HDDID, int?PSUID, int?OSID, int?MonitorID, int?HeadsetID, int?KeyboardID, int?MouseID, int?SpeakerID, string Warranty, int?numFans, int?numSSDs, int?numHDDs, string pcType, int?Quantity, double?Price, string Image, bool?Active, int?Discount)
        {
            CRUDService.ServiceClient sr = new CRUDService.ServiceClient();
            cPC newPC = new cPC
            {
                active      = Active != null ? 1 : 0,
                case_id     = Convert.ToString(caseID),
                cooler_id   = Convert.ToString(coolerID),
                cpu_id      = Convert.ToString(CPUID),
                fan_id      = Convert.ToString(FanID),
                gpu_id      = Convert.ToString(GPUID),
                headset_id  = Convert.ToString(HeadsetID),
                hdd_id      = Convert.ToString(HDDID),
                keyboard_id = Convert.ToString(KeyboardID),
                mobo_id     = Convert.ToString(moboID),
                monitor_id  = Convert.ToString(MonitorID),
                mouse_id    = Convert.ToString(MouseID),
                os_id       = Convert.ToString(OSID),
                psu_id      = Convert.ToString(PSUID),
                ram_id      = Convert.ToString(RAMID),
                ssd_id      = Convert.ToString(SSDID),
                speaker_id  = Convert.ToString(SpeakerID),
                discount    = Discount != null ? (int)Discount : 0,
                num_fans    = numFans != null ? (int)numFans : 0,
                num_hdd     = numHDDs != null ? (int)numHDDs : 0,
                num_ssd     = numSSDs != null ? (int)numSSDs : 0,
                price       = Price != null ? (double)Price : 0,
                type        = pcType,
                warranty    = Warranty,
            };
            bool added = sr.addPC(newPC, Quantity == null ? 0:(int)Quantity, Image);

            if (added)
            {
                return(this.RedirectToAction("Index", "AddnewProduct"));
            }
            else
            {
                return(this.RedirectToAction("PC", "AddnewProduct"));
            }
        }