public async Task <ActionResult <OfficeDetail> > PostOfficeDetail(OfficeDetail officeDetail)
        {
            _context.OfficeDetail.Add(officeDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOfficeDetail", new { id = officeDetail.OfficeId }, officeDetail));
        }
Esempio n. 2
0
        public async Task <ApiResponse> Handle(AddNewEmployeeCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                EmployeeDetail obj = _mapper.Map <EmployeeDetail>(request);
                obj.IsDeleted = false;
                await _dbContext.EmployeeDetail.AddAsync(obj);

                await _dbContext.SaveChangesAsync();

                OfficeDetail OfficeDetail = await _dbContext.OfficeDetail.FirstOrDefaultAsync(x => x.OfficeId == request.OfficeId && x.IsDeleted == false);

                EmployeeDetail emp = await _dbContext.EmployeeDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.EmployeeID == obj.EmployeeID);

                emp.EmployeeCode = "E" + obj.EmployeeID;
                _dbContext.EmployeeDetail.Update(emp);
                await _dbContext.SaveChangesAsync();

                EmployeeProfessionalDetailModel empprofessional = new EmployeeProfessionalDetailModel
                {
                    EmployeeId     = obj.EmployeeID,
                    EmployeeTypeId = request.EmployeeTypeId,
                    OfficeId       = request.OfficeId,
                    CreatedById    = request.CreatedById,
                    CreatedDate    = request.CreatedDate,
                    IsDeleted      = request.IsDeleted,
                    ProfessionId   = request.ProfessionId,
                    TinNumber      = request.TinNumber
                };
                EmployeeProfessionalDetail obj1 = _mapper.Map <EmployeeProfessionalDetail>(empprofessional);
                await _dbContext.EmployeeProfessionalDetail.AddAsync(obj1);

                await _dbContext.SaveChangesAsync();

                UserDetails user = await _dbContext.UserDetails.FirstOrDefaultAsync(x => x.AspNetUserId == request.CreatedById && x.IsDeleted == false);

                LoggerDetailsModel loggerObj = new LoggerDetailsModel();
                loggerObj.NotificationId = (int)Common.Enums.LoggerEnum.EmployeeCreated;
                loggerObj.IsRead         = false;
                loggerObj.UserName       = user.FirstName + " " + user.LastName;
                loggerObj.UserId         = request.CreatedById;
                loggerObj.LoggedDetail   = "Employee " + obj.EmployeeName + " Created";
                loggerObj.CreatedDate    = request.CreatedDate;

                response.LoggerDetailsModel = loggerObj;

                await _dbContext.SaveChangesAsync();

                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = StaticResource.SomethingWrong + ex.Message;
            }
            return(response);
        }
        public async Task <IActionResult> PutOfficeDetail(int id, OfficeDetail officeDetail)
        {
            if (id != officeDetail.OfficeId)
            {
                return(BadRequest());
            }

            _context.Entry(officeDetail).State = EntityState.Modified;

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

            return(NoContent());
        }
        public ActionResult Login2(Account objUser)
        {
            using (dbcontext db = new dbcontext())
            {
                DateTime     enddate = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd"));
                OfficeDetail detail  = db.OfficeDetails.Where(x => x.ValidKey != "").FirstOrDefault();
                if (detail != null)
                {
                    var obj = db.Accounts.Where(a => a.UserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).FirstOrDefault();
                    if (obj != null)
                    {
                        Session["UserID"]   = obj.UserName.ToString();
                        Session["UserName"] = obj.Password.ToString();
                        return(RedirectToAction("Index", "Preforms"));
                    }
                }
                else
                {
                    ViewBag.Message = string.Format("Sorry Your Licence Expire ! Please Contact to Official Solutions", DateTime.Now.ToString());
                    return(View("Login"));
                }
            }

            return(View(objUser));
        }
Esempio n. 5
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            OfficeDetail officeDetail = await db.OfficeDetails.FindAsync(id);

            db.OfficeDetails.Remove(officeDetail);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            OfficeDetail officeDetail = await db.OfficeDetails.FindAsync(id);

            db.OfficeDetails.Remove(officeDetail);
            this.SetNotification("Office Detail Deleted SucessFully", NotificationEnumeration.Error);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public async Task <ActionResult> Edit([Bind(Include = "id,CompanyName,Address,Phone,GSTNo,Email,UserName,Password,LicenceKey,StartDate,EndDate,AlertDays,ValidKey,smsUsername,SenderId,API,SMSActive")] OfficeDetail officeDetail)
        {
            if (ModelState.IsValid)
            {
                db.Entry(officeDetail).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(officeDetail));
        }
Esempio n. 8
0
        public async Task <ActionResult> Edit([Bind(Include = "id,CompanyName,Address,Phone,GSTNo,Email,Password")] OfficeDetail officeDetail)
        {
            if (ModelState.IsValid)
            {
                db.Entry(officeDetail).State = EntityState.Modified;
                await db.SaveChangesAsync();

                this.SetNotification("Office Detail Edit SucessFully", NotificationEnumeration.Success);
                return(RedirectToAction("Index"));
            }
            return(View(officeDetail));
        }
Esempio n. 9
0
        // GET: OfficeDetails/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OfficeDetail officeDetail = await db.OfficeDetails.FindAsync(id);

            if (officeDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(officeDetail));
        }
Esempio n. 10
0
        public async Task <ApiResponse> Handle(AddOfficeDetailCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                var existoffice = await _dbContext.OfficeDetail.FirstOrDefaultAsync(o => o.OfficeCode == request.OfficeCode); //use only OfficeCode

                if (existoffice == null)
                {
                    OfficeDetail obj = new OfficeDetail
                    {
                        OfficeCode     = request.OfficeCode,
                        OfficeName     = request.OfficeName,
                        SupervisorName = request.SupervisorName,
                        PhoneNo        = request.PhoneNo,
                        FaxNo          = request.FaxNo,
                        OfficeKey      = request.OfficeKey,
                        IsDeleted      = false,
                        CreatedById    = request.CreatedById,
                        CreatedDate    = DateTime.UtcNow
                    };

                    await _dbContext.OfficeDetail.AddAsync(obj);

                    await _dbContext.SaveChangesAsync();

                    response.StatusCode = StaticResource.successStatusCode;
                    response.Message    = "Success";
                }
                else
                {
                    response.StatusCode = StaticResource.MandateNameAlreadyExistCode;
                    response.Message    = StaticResource.MandateNameAlreadyExist;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
Esempio n. 11
0
        public ActionResult SMS(int id, Helper help, string Message, int status)
        {
            PreForm        pp = db.PreForms.Where(x => x.Preformid == id).First();
            ProcessingForm pf = db.ProcessingForms.Where(x => x.Preformid == id).First();
            OfficeDetail   of = db.OfficeDetails.FirstOrDefault();

            if (status == 1)
            {
                // processing fee sms
                output = help.smssetting(pp.ContactNo, "Dear " + pp.StudentName + ". Your Processing Fees is:" + pf.ProcessingFee + " and your Due Date Is : " + pf.ProcessAlertDate + " Thanks and Regards " + of.CompanyName + "");
            }
            else if (status == 2)
            {
                // college fee alert
                output = help.smssetting(pp.ContactNo, "Dear " + pp.StudentName + ". Your College Fees is:" + pf.CollegeFee + " and your Due Date Is : " + pf.CollegeAlertDate + " Thanks and Regards " + of.CompanyName + "");
            }
            else if (status == 3)
            {
                // GIC fee alert
                output = help.smssetting(pp.ContactNo, "Dear " + pp.StudentName + ". Your GIC Fees is:" + pf.GICFee + " and your Due Date Is : " + pf.GICAlertDate + " Thanks and Regards " + of.CompanyName + "");
            }
            else if (status == 3)
            {
                // Embassy fee alert
                output = help.smssetting(pp.ContactNo, "Dear " + pp.StudentName + ". Your Embassy Fees is:" + pf.EmbassyFee + " and your Due Date Is : " + pf.EmbassyAlertDate + " Thanks and Regards " + of.CompanyName + "");
            }

            if (output == "Done")
            {
                this.SetNotification("Your Alert Message Send Sucessfully To " + pp.StudentName + "", NotificationEnumeration.Success);
            }
            else if (output == "SMS Not Activated")
            {
                this.SetNotification("SMS Sending Failed", NotificationEnumeration.Warning);
            }
            else
            {
                this.SetNotification("Message Not Send !", NotificationEnumeration.Error);
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ApiResponse> Handle(EditVoucherDetailCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                request.TimezoneOffset = request.TimezoneOffset > 0 ? request.TimezoneOffset * -1 : Math.Abs(request.TimezoneOffset.Value);

                DateTime filterVoucherDate = request.VoucherDate.AddMinutes(request.TimezoneOffset.Value);

                Task <List <CurrencyDetails> >    currencyListTask        = _dbContext.CurrencyDetails.Where(x => x.IsDeleted == false).ToListAsync();
                Task <List <ExchangeRateDetail> > exchangeRatePresentTask = _dbContext.ExchangeRateDetail.Where(x => x.Date.Date == request.VoucherDate.Date && x.IsDeleted == false).ToListAsync();
                Task <VoucherDetail>   voucherDetailTask   = _dbContext.VoucherDetail.FirstOrDefaultAsync(c => c.VoucherNo == request.VoucherNo);
                Task <OfficeDetail>    officeDetailTask    = _dbContext.OfficeDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.OfficeId == request.OfficeId);
                List <CurrencyDetails> currencyDetailsList = await currencyListTask;

                var currencyList = currencyDetailsList.Select(x => x.CurrencyId).ToList();

                List <ExchangeRateDetail> exchangeRatePresent = await exchangeRatePresentTask;

                if (CheckExchangeRateIsPresent(currencyList, exchangeRatePresent))
                {
                    VoucherDetail voucherdetailInfo = await voucherDetailTask;

                    string currencyCode = currencyDetailsList.FirstOrDefault(x => x.CurrencyId == request.CurrencyId).CurrencyCode;

                    int voucherCount = await _dbContext.VoucherDetail.Where(x => x.VoucherDate.Month == filterVoucherDate.Month && x.OfficeId == request.OfficeId && x.VoucherDate.Year == filterVoucherDate.Year).CountAsync();

                    if (voucherdetailInfo != null)
                    {
                        OfficeDetail officeDetail = await officeDetailTask;

                        if (request.VoucherDate.Date != voucherdetailInfo.VoucherDate.Date || request.OfficeId != voucherdetailInfo.OfficeId || voucherdetailInfo.CurrencyCode != request.CurrencyCode)
                        {
                            string referenceNo = AccountingUtility.GenerateVoucherReferenceCode(filterVoucherDate, voucherCount, currencyCode, officeDetail.OfficeCode);

                            if (!string.IsNullOrEmpty(referenceNo))
                            {
                                //check if same sequence number is already present in the voucher table
                                int sameVoucherReferenceNoCount = 0;

                                do
                                {
                                    sameVoucherReferenceNoCount = await _dbContext.VoucherDetail.Where(x => x.ReferenceNo == referenceNo).CountAsync();

                                    if (sameVoucherReferenceNoCount == 0)
                                    {
                                        voucherdetailInfo.ReferenceNo = referenceNo;
                                    }
                                    else
                                    {
                                        var refNo = referenceNo.Split('-');
                                        int count = Convert.ToInt32(refNo[3]);
                                        referenceNo = AccountingUtility.GenerateVoucherReferenceCode(request.VoucherDate, count, currencyCode, officeDetail.OfficeCode);
                                    }
                                }while (sameVoucherReferenceNoCount != 0);
                            }
                        }
                        else if (request.CurrencyId != voucherdetailInfo.CurrencyId)
                        {
                            if (string.IsNullOrEmpty(voucherdetailInfo.ReferenceNo))
                            {
                                var refNo = voucherdetailInfo.ReferenceNo.Split('-');
                                refNo[1] = currencyCode;
                                voucherdetailInfo.ReferenceNo = refNo[0] + "-" + refNo[1] + "-" + refNo[2] + "-" + refNo[3] + "-" + refNo[4];
                            }
                            else
                            {
                                throw new Exception("Reference No cannot be set");
                            }
                        }

                        voucherdetailInfo.CurrencyId      = request.CurrencyId;
                        voucherdetailInfo.OfficeId        = request.OfficeId;
                        voucherdetailInfo.VoucherDate     = request.VoucherDate;
                        voucherdetailInfo.ChequeNo        = request.ChequeNo;
                        voucherdetailInfo.JournalCode     = request.JournalCode;
                        voucherdetailInfo.FinancialYearId = request.FinancialYearId;
                        voucherdetailInfo.VoucherTypeId   = request.VoucherTypeId;
                        voucherdetailInfo.Description     = request.Description;
                        voucherdetailInfo.ModifiedById    = request.ModifiedById;
                        voucherdetailInfo.ModifiedDate    = request.ModifiedDate;

                        _dbContext.VoucherDetail.Update(voucherdetailInfo);
                        await _dbContext.SaveChangesAsync();

                        if (await _dbContext.VoucherTransactions.AnyAsync(x => x.VoucherNo == voucherdetailInfo.VoucherNo))
                        {
                            var voucherTransactions = await _dbContext.VoucherTransactions.Where(x => x.VoucherNo == voucherdetailInfo.VoucherNo).ToListAsync();

                            foreach (var transaction in voucherTransactions)
                            {
                                transaction.TransactionDate = voucherdetailInfo.VoucherDate;
                            }

                            _dbContext.VoucherTransactions.UpdateRange(voucherTransactions);
                            await _dbContext.SaveChangesAsync();
                        }

                        response.StatusCode = StaticResource.successStatusCode;
                        response.Message    = StaticResource.SuccessText;
                    }
                    else
                    {
                        response.StatusCode = StaticResource.failStatusCode;
                        response.Message    = StaticResource.VoucherNotPresent;
                    }
                }
                else
                {
                    response.StatusCode = StaticResource.failStatusCode;
                    response.Message    = StaticResource.ExchagneRateNotDefined;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }