コード例 #1
0
ファイル: PaymentRepository.cs プロジェクト: ootybinu/ang
        public string Authenticate(string date)
        {
            var result = "Success";

            try
            {
                var userid    = Context.GetUser();
                var emp       = (from empl in EmployeeLoginMapping where empl.employeeid == userid select empl).FirstOrDefault();
                var empDetail = (from empl in Employee where empl.employeeid == userid select empl).FirstOrDefault();
                var qry       = from pd in PaymentDetail
                                where pd.AddedAt.Date == Convert.ToDateTime(date).Date&& pd.Canceled == false
                                select pd;

                if (empDetail.divisionid != null)
                {
                    qry = from paydata in qry
                          join bill in Bill on paydata.BillNo equals bill.Id
                          join us in UnitSummary on bill.UnitId equals us.id
                          where us.divisionid == empDetail.divisionid
                          select paydata;
                }

                var authtime = DateTime.Now;
                var rows     = qry.ToList();

                foreach (var pd in rows)
                {
                    pd.Authenticated = true;
                    pd.AuthAt        = authtime;
                    pd.AuthBy        = emp.loginname;
                }
                PaymentDetail.UpdateRange(rows);
                this.SaveChanges();
            }
            catch (Exception ex)
            {
                result = "Failed :" + ex.Message;
            }
            return(result);
        }