コード例 #1
0
        public string accept(Int64 id)
        {
            var leave = context.Leaves.Find(id);


            if (leave != null)
            {
                leave.Action         = "Accept";
                leave.CurrentBalance = leave.CurrentBalance - leave.Days;
                //if (leave.CurrentBalance == 0)
                //{
                //    leave.CurrentBalance = 25 - leave.Days;
                //}
                //else
                //{
                //    leave.CurrentBalance = leave.CurrentBalance - leave.Days;
                //}


                context.Entry(leave).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
                response.IsSuccess = true;
                response.Data      = leave;
                response.Message   = "Record Accept successfully!";
            }

            return(JsonConvert.SerializeObject(response));
        }
コード例 #2
0
        public string UpdateLeave(Int64 AlocatedLeaves)
        {
            var adminlist = context.Admins.ToList();

            foreach (var admin in adminlist)
            {
                var ab = AlocatedLeaves - admin.AlocatedLeaves;
                admin.CurrentBalance = admin.CurrentBalance + ab;
                admin.AlocatedLeaves = AlocatedLeaves;


                context.Entry(admin).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
                response.IsSuccess = true;
                response.Message   = "Record updated succesfully";
            }
            return(JsonConvert.SerializeObject(response));
        }
コード例 #3
0
        public string Update(AbsencenameView absencenameview)
        {
            if (string.IsNullOrEmpty(absencenameview.AbsenceType))
            {
                response.Message   = "Please provide TYpe name";
                response.IsSuccess = false;
                return(JsonConvert.SerializeObject(response));
            }



            var absencename = AutoMapper.Mapper.Map <Absencename>(absencenameview);

            context.Entry(absencename).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();
            response.IsSuccess = true;
            response.Message   = "Record updated succesfully";

            return(JsonConvert.SerializeObject(response));
        }