Esempio n. 1
0
        public IHttpActionResult PutDataOvertime(int id, DataOvertime dataOvertime)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DataOvertimeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public bool Insert(DataOvertimeVM dataOvertimeVM)
        {
            var push          = new DataOvertime(dataOvertimeVM);
            var getSubmitedId = myContext.Submiteds.Find(dataOvertimeVM.Submited_Id);

            push.Submited = getSubmitedId;
            var getTypeId = myContext.TypeOvertimes.Find(dataOvertimeVM.Type_Id);

            if (getSubmitedId != null)
            {
                push.TypeOvertime = getTypeId;
                myContext.DataOvertimes.Add(push);
                var result = myContext.SaveChanges();
                if (result > 0)
                {
                    status = true;
                    return(status);
                }
                else
                {
                    return(status);
                }
            }
            else
            {
                return(status);
            }
        }
        //Method Delete digunakan untuk menghapus data dari tabel dataovertime
        public int Delete(int input)
        {
            DataOvertime dataovertime = _context.DataOvertimes.Find(input);

            _context.Entry(dataovertime).State = System.Data.Entity.EntityState.Deleted;
            _context.SaveChanges();

            return(input);
        }
Esempio n. 4
0
        public void Insert(DataOvertimeParam param)
        {
            var employee = db.Employees.Find(Convert.ToInt32(param.Employees));
            var type     = db.OverTimeTypes.Find(Convert.ToInt32(param.OvertimeTypes));
            var ot       = new DataOvertime(param.Date, param.Status, param.Price, employee, type);

            db.DataOvertimes.Add(ot);
            db.SaveChanges();
        }
 public DataOvertimeParam(DataOvertime ot)
 {
     Id            = ot.Id;
     Date          = ot.Date;
     Status        = ot.Status;
     Price         = ot.Price;
     Employees     = ot.Employees.ToString();
     OvertimeTypes = ot.OvertimeTypes.ToString();
 }
Esempio n. 6
0
        public IHttpActionResult GetDataOvertime(int id)
        {
            DataOvertime dataOvertime = db.DataOvertimes.Find(id);

            if (dataOvertime == null)
            {
                return(NotFound());
            }

            return(Ok(dataOvertime));
        }
Esempio n. 7
0
        public IHttpActionResult PostDataOvertime(DataOvertime dataOvertime)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DataOvertimes.Add(dataOvertime);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = dataOvertime.Id }, dataOvertime));
        }
Esempio n. 8
0
        public IHttpActionResult DeleteDataOvertime(int id)
        {
            DataOvertime dataOvertime = db.DataOvertimes.Find(id);

            if (dataOvertime == null)
            {
                return(NotFound());
            }

            db.DataOvertimes.Remove(dataOvertime);
            db.SaveChanges();

            return(Ok(dataOvertime));
        }
        //Method Update untuk mengupdate status pada tabel dataovertime
        public int Update(int input)
        {
            Console.Write("Masukkan Status Baru   :");
            string new_status = Console.ReadLine();

            var getover = _context.DataOvertimes.Find(input);

            if (getover == null)
            {
                Console.WriteLine("Id yang dicari tidak ada");
            }
            else
            {
                DataOvertime dataovertime = searchId(input);
                dataovertime.status = new_status;

                _context.Entry(dataovertime).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
            return(input);
        }
        public void Insert()
        {
            Console.Write("Masukkan Nomor Karyawan  : ");
            int empID = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan Kode Jenis Pajak : ");
            int taxID = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan Kode Jenis Overtime : ");
            int overtimeID = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan Kode Customer : ");
            int customerID = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan Tanggal Overtime : ");
            DateTime tanggal = Convert.ToDateTime(Console.ReadLine());


            DataOvertime dataOvertime = new DataOvertime()
            {
                employeeID     = empID,
                taxID          = taxID,
                overtimeTypeID = overtimeID,
                customerID     = customerID,
                date           = tanggal,
                status         = "Pending"
            };

            try
            {
                _context.DataOvertimes.Add(dataOvertime);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                Console.Write(e.InnerException);
                Console.Write(e.Message);
                Console.Write(e.StackTrace);
            }
        }
Esempio n. 11
0
        public bool Insert(DataOvertimeVM dataOvertimeVM)
        {
            var push = new DataOvertime(dataOvertimeVM);
            var get  = myContext.TypeOvertimes.Find(dataOvertimeVM.Type_Id);

            if (get != null)
            {
                push.TypeOvertime = get;
                myContext.DataOvertimes.Add(push);
                var result = myContext.SaveChanges();
                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }