private static tbl_SMSSenderInfo GetShortAverageCost(string senderName) { CRUDOperation cRUDOperation = new CRUDOperation(); tbl_SMSSenderInfo senderInfo = cRUDOperation.GetSMSSenderInfoByName(senderName); return(senderInfo); }
public ActionResult Edit(int id, string senderName) { SMSSenderInfoVM viewModel = new SMSSenderInfoVM(); CRUDOperation dataOperations = new CRUDOperation(); viewModel = poulateDropDownList(viewModel); if (id > 0) { tbl_SMSSenderInfo tblItem = dataOperations.GetSMSSenderInfoByID(id); viewModel.ID = id; viewModel.ActivityTypeEVID = tblItem.ActivityType; viewModel.SenderName = tblItem.SenderName; viewModel.Description = tblItem.Description; viewModel.Number = tblItem.Number; viewModel.Price = tblItem.Price; viewModel.Point = tblItem.Point; viewModel.Cheque = tblItem.Cheque; } else { viewModel.SenderName = senderName; } return(View(viewModel)); }
public ActionResult Create(SMSSenderInfoVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_SMSSenderInfo item = new tbl_SMSSenderInfo() { ActivityType = viewModel.ActivityTypeEVID, SenderName = viewModel.SenderName, Description = viewModel.Description, Number = viewModel.Number, Price = viewModel.Price, Point = viewModel.Point, Cheque = viewModel.Cheque, InsertDate = DateTime.Now, InsertUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_SMSSenderInfo sMSSenderInfoControl = dataOperations.GetSMSSenderInfoByName(item.SenderName); if (sMSSenderInfoControl != null) { TempData["success"] = "notOk"; TempData["message"] = "Eyni parametrelerə sahib məlumat sistemdə mövcudur"; return(RedirectToAction("Index")); } else { tbl_SMSSenderInfo dbItem = dataOperations.AddSMSSenderInfo(item); if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla əlavə olundu"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi"; return(RedirectToAction("Index")); } } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { viewModel = poulateDropDownList(viewModel); return(View(viewModel)); } }
public ActionResult Edit(SMSSenderInfoVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_SMSSenderInfo item = new tbl_SMSSenderInfo() { ID = viewModel.ID, ActivityType = viewModel.ActivityTypeEVID, SenderName = viewModel.SenderName, Description = viewModel.Description, Number = viewModel.Number, Price = viewModel.Price, Point = viewModel.Point, Cheque = viewModel.Cheque, IsParse = viewModel.IsParse, UpdateDate = DateTime.Now, UpdateUser = UserProfile.UserId }; tbl_SMSSenderInfo dbItem = null; CRUDOperation dataOperations = new CRUDOperation(); if (viewModel.ID > 0) { dbItem = dataOperations.UpdateSMSSenderInfo(item); } else { dbItem = dataOperations.AddSMSSenderInfo(item); } if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla dəyişdirildi"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar dəyişdirilərkən xəta baş verdi"; return(RedirectToAction("Index")); } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { viewModel = poulateDropDownList(viewModel); return(View(viewModel)); } }
public IHttpActionResult AddSMSSenderInfo(tbl_SMSSenderInfo item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CRUDOperation operation = new CRUDOperation(); tbl_SMSSenderInfo dbitem = operation.AddSMSSenderInfo(item); return(Ok(dbitem)); }
public IHttpActionResult UpdateSMSSenderInfo(tbl_SMSSenderInfo item) { CRUDOperation operation = new CRUDOperation(); if (item == null) { return(NotFound()); } else { var dbitem = operation.UpdateSMSSenderInfo(item); return(Ok(dbitem)); } }
public void AddSMSReportDetail(Int64 userID, string phoneNumer, tbl_SMSDetail detailItem, tbl_SMSSenderInfo smsSenderInfo) { CRUDOperation cRUDOperation = new CRUDOperation(); int _outMsjCountSame = 0, _outMsjCountOther = 0, _outMsjForeignCount = 0, _outMsjRoamingCount = 0; int _inMsjCount = 0, _inMsjForeignCount = 0; tbl_OperatorInformation _OperatorInformation = new tbl_OperatorInformation(); decimal pointValue = 0; decimal priceValue = 0; int month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0; int year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0; try { if (detailItem.IsShortMessage == 0) { if (detailItem.InOutType == 1) { if (detailItem.IsForeign == 0 || detailItem.IsForeign == null) { bool IsSame = NumberHelper.ControlSameOrOther(phoneNumer, detailItem.PhonePrefix); if (IsSame) { _outMsjCountSame = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutSameCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } else { _outMsjCountOther = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutOtherCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } } else if (detailItem.IsForeign == 1) { _outMsjForeignCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.OutSameCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } } else { if (detailItem.IsForeign == 0 || detailItem.IsForeign == null) { _inMsjCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.INCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } else if (detailItem.IsForeign == 1) { _inMsjForeignCount = 1; _OperatorInformation = cRUDOperation.GetOperatorInformationByPrefixAndType(NumberHelper.GetNumberPrefix(phoneNumer), (int)SMSOperatorInformation.INCount, (int)OperatorChanelType.Message); if (_OperatorInformation != null) { pointValue = 1 * _OperatorInformation.Point == null ? 0 : (decimal)_OperatorInformation.Point; priceValue = 1 * _OperatorInformation.Price == null ? 0 : (decimal)_OperatorInformation.Price; AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } } } tbl_SMSReport smsReport = new tbl_SMSReport() { SMSModelID = detailItem.SMSModelID, SMSDetailID = detailItem.ID, UserID = userID, Month = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Month : 0, Year = detailItem.RecievedDate.HasValue == true ? detailItem.RecievedDate.Value.Year : 0, OutMsjCountSame = _outMsjCountSame, OutMsjCountOther = _outMsjCountOther, OutMsjForeignCount = _outMsjForeignCount, InMsjCount = _inMsjCount, InMsjForeignCount = _inMsjForeignCount, }; cRUDOperation.AddSMSReport(smsReport); } else if (detailItem.IsShortMessage == 1) { if (smsSenderInfo != null) { pointValue = 1 * (smsSenderInfo.Point == null ? 0 : (decimal)smsSenderInfo.Point); priceValue = 1 * (smsSenderInfo.Price == null ? 0 : (decimal)smsSenderInfo.Price); AddUserPointAndPrice(userID, month, year, pointValue, priceValue, (int)ChanelType.SMS); } if (detailItem.IsParse == 1) { if (detailItem.SenderName == "Azericard") { tbl_SMSReportShort smsRepotShort = ParseAzeriCard(detailItem, userID); //Mebleg:-30.00 AZN if (smsRepotShort != null) { cRUDOperation.AddSMSReportShort(smsRepotShort); decimal priceAzeriCardValue = 0; priceAzeriCardValue = smsRepotShort.Amount; if (smsRepotShort.IsExpense == 1) { if (smsRepotShort.Currency == "AZN") { AddUserPointAndPrice(userID, month, year, 0, priceAzeriCardValue, (int)ChanelType.AzeriCard); AddUserExpenseAbility(userID, "Azericard", "Xərc", month, year, priceAzeriCardValue, (int)ChanelType.AzeriCard); } } else { AddUserIncomeAbility(userID, true, "Azericard", "Gəlir", month, year, priceAzeriCardValue, (int)ChanelType.AzeriCard); } } } if (detailItem.SenderName.ToLower() == "bakcell") { tbl_SMSReportShort smsRepotShort = ParseBakcell(detailItem, userID); //Mebleg:-30.00 AZN if (smsRepotShort != null) { cRUDOperation.AddSMSReportShort(smsRepotShort); if (smsRepotShort.IsExpense == 1) { AddUserPointAndPrice(userID, month, year, 0, smsRepotShort.Amount, (int)ChanelType.Bakcell); AddUserExpenseAbility(userID, "Bakcell", "Kontur", month, year, smsRepotShort.Amount, (int)ChanelType.Bakcell); AddUserIncomeAbility(userID, false, "Bakcell", "Kontur", month, year, smsRepotShort.Amount, (int)ChanelType.Bakcell); } } } } } } catch (Exception ex) { } }
public List <SMSReportDTO> SW_GetSMSReportShortMsjs(int userID, string userName, int year) { var result = new List <SMSReportDTO>(); StringBuilder allQuery = new StringBuilder(); var query = @"select * from [GetMessageReportShortSMS](@P_USERID,@P_year) "; allQuery.Append(query); using (var connection = new SqlConnection(ConnectionStrings.ConnectionString)) { connection.Open(); using (var command = new SqlCommand(allQuery.ToString(), connection)) { SqlParameter puserID = new SqlParameter("@P_USERID", SqlDbType.Int); puserID.Value = userID; command.Parameters.Add(puserID); SqlParameter pyear = new SqlParameter("@P_year", SqlDbType.Int); pyear.Value = year; command.Parameters.Add(pyear); //command.Parameters.AddWithValue("@P_USERID", userID); //command.Parameters.AddWithValue("@P_year", year); var reader = command.ExecuteReader(); while (reader.Read()) { SMSReportDTO sMSReportDTO = new SMSReportDTO() { INOUT_EVType = reader.GetInt32OrDefaultValue(0), Name = reader.GetStringOrEmpty(1), OperationType = reader.GetStringOrEmpty(2), Year = reader.GetInt32OrDefaultValue(3), January = reader.GetInt32OrNull(4), February = reader.GetInt32OrNull(5), March = reader.GetInt32OrNull(6), April = reader.GetInt32OrNull(7), May = reader.GetInt32OrNull(8), June = reader.GetInt32OrNull(9), July = reader.GetInt32OrNull(10), August = reader.GetInt32OrNull(11), September = reader.GetInt32OrNull(12), October = reader.GetInt32OrNull(13), November = reader.GetInt32OrNull(14), December = reader.GetInt32OrNull(15), }; sMSReportDTO.Average = GetAverageShort(sMSReportDTO); string senderName = string.Empty; try { senderName = sMSReportDTO.Name.Split(' ')[0]; } catch (Exception ex) { } tbl_SMSSenderInfo senderInfo = GetShortAverageCost(senderName); if (senderInfo != null) { if (senderInfo.Price == null) { sMSReportDTO.AveragePrice = null; } else { sMSReportDTO.AveragePrice = sMSReportDTO.Average * (decimal)senderInfo.Price;; } if (senderInfo.Point == null) { sMSReportDTO.AveragePoint = null; } else { sMSReportDTO.AveragePoint = sMSReportDTO.Average * (decimal)senderInfo.Point;; } } result.Add(sMSReportDTO); } } connection.Close(); } return(result); }