Ejemplo n.º 1
0
        public ActionResult EditWatchList(int? id)
        {
            var watchListModel = new WatchListModel();

            // Fetch watchlist details if it is in edit mode else simply pass an empty model to the view.
            if (id != null && id.Value > 0)
            {
                watchListModel = this.GetWatchListEntityModel(id.Value);
            }

            return View("Edit", watchListModel);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Converts a WatchListModel to WatchListEntity.
 /// </summary>
 /// <param name="watchListModel">WatchListModel to be converted to WatchListEntity.</param>
 /// <returns>WatchListEntity corresponding to WatchListModel.</returns>
 public static WatchListEntity ConvertModelToWatchListEntity(WatchListModel watchListModel)
 {
     return(new WatchListEntity
     {
         AlertRequired = watchListModel.AlertRequired,
         AltNameOne = watchListModel.AltNameOne,
         AltNameThree = watchListModel.AltNameThree,
         AltNameTwo = watchListModel.AltNameTwo,
         BseSymbol = watchListModel.BseSymbol,
         CreatedOn = !string.IsNullOrEmpty(watchListModel.CreatedOn) ?
                     DataFormatter.GetDateTimeInUtcFormat(DataFormatter.FormatStringToDate(watchListModel.CreatedOn)) : null,
         IsActive = watchListModel.IsActive,
         ModifiedOn = !string.IsNullOrEmpty(watchListModel.ModifiedOn) ?
                      DataFormatter.GetDateTimeInUtcFormat(DataFormatter.FormatStringToDate(watchListModel.ModifiedOn)) : null,
         Name = watchListModel.Name,
         NseSymbol = watchListModel.NseSymbol,
         TempName = watchListModel.TempName,
         WatchListID = watchListModel.WatchListID
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to save watch list entity.
        /// </summary>
        /// <param name="watchListModel">The watch list model to be saved.</param>
        /// <returns>Id of the watch list item that has been saved.</returns>
        private int SaveWatchListItem(WatchListModel watchListModel)
        {
            IWatchListBusiness iWatchListBusiness = new WatchListBusiness();

            return iWatchListBusiness.SaveWatchListItem(WatchListModel.ConvertModelToWatchListEntity(watchListModel));
        }
Ejemplo n.º 4
0
        public JsonResult EditWatchList(WatchListModel watchListModel)
        {
            // Set the date of creation and modification.
            if(watchListModel.WatchListID > 0)
            {
                watchListModel.ModifiedOn = DataFormatter.FormatDateToString(DateTime.Now);
            }
            else
            {
                watchListModel.CreatedOn = DataFormatter.FormatDateToString(DateTime.Now);
            }

            // Save the changes and return new grid model as JSON result if the save is successful.
            this.SaveWatchListItem(watchListModel);

            return Json(this.CreateWatchListGridModel(new GridContext {SortInfo = new GridSortInfo {SortOn = "Name"}}));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Converts a WatchListModel to WatchListEntity.
 /// </summary>
 /// <param name="watchListModel">WatchListModel to be converted to WatchListEntity.</param>
 /// <returns>WatchListEntity corresponding to WatchListModel.</returns>
 public static WatchListEntity ConvertModelToWatchListEntity(WatchListModel watchListModel)
 {
     return new WatchListEntity
     {
         AlertRequired = watchListModel.AlertRequired,
         AltNameOne = watchListModel.AltNameOne,
         AltNameThree = watchListModel.AltNameThree,
         AltNameTwo = watchListModel.AltNameTwo,
         BseSymbol = watchListModel.BseSymbol,
         CreatedOn = !string.IsNullOrEmpty(watchListModel.CreatedOn) ?
             DataFormatter.GetDateTimeInUtcFormat(DataFormatter.FormatStringToDate(watchListModel.CreatedOn)) : null,
         IsActive = watchListModel.IsActive,
         ModifiedOn = !string.IsNullOrEmpty(watchListModel.ModifiedOn) ?
             DataFormatter.GetDateTimeInUtcFormat(DataFormatter.FormatStringToDate(watchListModel.ModifiedOn)) : null,
         Name = watchListModel.Name,
         NseSymbol = watchListModel.NseSymbol,
         TempName = watchListModel.TempName,
         WatchListID = watchListModel.WatchListID
     };
 }